public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
three =one +two;
System.out.println("three =one +two==>"+three);
three += one ;
System.out.println("three += one ==>"+three);
three -= one;
System.out.println("three -=one ==>"+three);
three *= one;
System.out.println("three *=one ==>"+three);
three /=one;
System.out.println("three =one ==>"+three);
表示字符串和变量的拼接
双引号里面的内容是直接原样输出的,后面的three代表变量three的值,加号是连接两个字符串用的。
例如:System.out.println("three =one +two==>"+three);中引号内的three =one +two==>照样输出但是没有值,所以要添上+three将变量three的值也输出来。