Section super-simple to learn, Java concept, output, two simple classes Date Random
Mr. into .java Java source files compiled by javac command .class bytecode files, and then run through the java command.
1. Output
public class A {
public static void main(String[] args) {
System.out.println("该怎么形容你最贴切");
System.out.println("拿什么和你做比较才算特别");
}
}
2. Digital subtraction output
( "+") As in the output, after operation (+) in the output
public class B {
public static void main(String[] args) {
System.out.println("AHSD");
System.out.print("123+456=");
System.out.println(123+456);
}
}
operation result
3.Date class
public class E {
public static void main(String[] args) {
System.out.println("格林尼治时间为:"+System.currentTimeMillis());
Date now=new Date();
System.out.println(now);
//计算机从1900年开始计时
System.out.print((now.getYear()+1900)+"年");
//计算机的月份从0-11
System.out.print((now.getMonth()+1)+"月");
System.out.print(now.getDate()+"日");
//System.out.print("星期:"now.getDay());
System.out.print(now.getHours()+":");
System.out.print(+now.getMinutes()+":");
System.out.println(now.getSeconds());
}
}
operation result
4.Random class
Generates a random number, and controlled within 100
import java.util.Random;
public class F {
public static void main(String[] args) {
//随机数类
Random ran=new Random();
System.out.println("100以内的正整数:"+ran.nextInt(100));
}
}