可以直接拷贝运行. package year; import java.util.Scanner; public class year { public static void main(String[] args) { // TODO Auto-generated method stub year y = new year(); y.fun(); } public void fun(){ String str = shuru(); int year = Integer.parseInt(str
/*** 方法一*/ String strDate = "2012-02"; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); Date date = format.parse(strDate); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); int days1 = calendar.getActualMax
import java.text.SimpleDateFormat; import java.util.Calendar; public class Test { public static void main(String[] args) { //获取当前时间 Calendar cal = Calendar.getInstance(); //下面可以设置月份,注:月份设置要减1,所以设置1月就是1-1,设置2月就是2-1,如此类推 cal.set(Calendar.MONTH, 1-1); /
关系操作符==和 类的equals方法都可以用来比较两个类是否相同,但实际用起来却经常产生令JAVA新手迷惑的结果. 先看一段示例代码: public class HelloWorld { public static void main(String[] args) { // TODO Auto-generated method stub //System.getProperties().list(System.out); String str1 = new String("Hello worl
Problem Description Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO". Input each test case contains two numbers A and B. Output for each case, if A is equal to B, you should print "YES&qu
本文参考 本篇文章参考自<Effective Java>第三版第十一条"Always override hashCode when you override equals" You must override hashCode in every class that overrides equals hashCode()方法的通用约定如下: When the hashCode method is invoked on an object repeatedly during