2017/12/26 日常

1、接收一行用readline();read方法不能接收空格后的字符串;
2、素数是不能被除1和他本身数整除的数;
int i=0;
int j=0;
for( i=2;i<=100;i++){
for(j=2;j<i;j++){
if(i%j==0)
break;
}
if(j==i)
System.out.println(i+" ");
}
3、设置日期格式:
SimpleDateFormat simple1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat simple2=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
Date date=new Date();
System.out.println(simple1.format(date));
System.out.println(simple2.format(date));
4、导包的时候注意不要导入sql.Date,是Util.Date;
5、String name="assa";定义时使用了串池技术,串池是一段字符串的缓冲区。有内容相同的字符串对象时,将指向串池中已存在的对象;
使用==比较时,会相同;

原文地址:https://www.cnblogs.com/loong996/p/8120407.html