package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args){
System.out.println("Hello world");
Scanner in = new Scanner(System.in);
System.out.println(in.nextLine());
}
}
------------------------
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args){
System.out.println("Hello world");
Scanner in = new Scanner(System.in);
System.out.println("echo:"+in.nextLine()); //用"+"连接两个字符串,""里面的内容为固定输出
}
}
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args){
// System.out.println("Hello world");
// Scanner in = new Scanner(System.in);
// System.out.println("echo:"+in.nextLine());
System.out.println("2+3="+5); //输出2+3=5用+把前面的字符串和后面的内容连接起来,则+后面的内容也变成字符串输出
}
}
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args){
// System.out.println("Hello world");
// Scanner in = new Scanner(System.in);
// System.out.println("echo:"+in.nextLine());
System.out.println("2+3="+2+3); // 输出2+3=23
}
}
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args){
// System.out.println("Hello world");
// Scanner in = new Scanner(System.in);
// System.out.println("echo:"+in.nextLine());
System.out.println("2+3="+(2+3)); //输出2+3=5括号决定运算顺序,先计算括号里面的2+3,再做字符串连接
}
}
package hello;
import java.util.Scanner;
public class Hello {
public static void main(String[] args){
// System.out.println("Hello world");
// Scanner in = new Scanner(System.in);
// System.out.println("echo:"+in.nextLine());
System.out.println(2+3+"=2+3="+(2+3)); // 输出5=2+3=5,先计算最前面的2+3,在计算括号里面的2+3,再做字符串连接
}
}