public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int age = scanner.nextInt(); String name = scanner.nextLine(); double salary = scanner.nextDouble(); System.out.println(age); System.out.println(name); System.out.println(salary); } } 1. 2. 3. 4....
doubleb){returna+b;}}publicclassMain{publicstaticvoidmain(String[]args){Calculatorcalc=newCalculator();System.out.println(calc.add(5,3));// 解析成功System.out.println(calc.add(5.0,3));// 解析失败:无法区分 int 和 double}}
我的输入字符串没有区域: String formatter = "yyyy-MM-dd"; String zone = "Europe/London"; String date = ZonedDateTime.now(ZoneId.of(zone)).format( DateTimeFormatter.ofPattern(formatter)); System.out.println("date: " + date); // ZonedDateTime dateTime = ZonedDateTime.parse(date , DateTim...
("i am a dog") } func (c cat) say() { fmt.Println("i am a cat") } 2 值方法和指针方法 golang中定义一个方法形式为 func...接收者有两种形式,一种是值类型,一种是指针类型。下面的dog say为指针类型,cat say为值类型。...type dog struct{} type cat struct{} // say()方法的全名为...