A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

    public class Main {  
      
        public static void main(String[] args) {  
            // TODO Auto-generated method stub  
            int a =3,b;  
            b=a++;//先赋值给B,再进行a++运算  
            System.out.println("a="+a+",b="+b);  
        }  
      
    }  

输出:a=4,b=3


[java] view plain copy

    public class Main {  
      
        public static void main(String[] args) {  
            // TODO Auto-generated method stub  
            int a =3,b;  
            b=++a;//先进行a++运算,再赋值给b  
            System.out.println("a="+a+",b="+b);  
        }  
      
    }  


输出:a=4,b=4


[java] view plain copy

    public class Demo {  
        public static void main(String args[]){  
            int x=4270;  
            x=x/1000*1000;//x为int型数据类型,所以在进行运算后也是int型数据。  
            System.out.println(x);  
        }  
    }  


输出:4000



[java] view plain copy

    public class Demo1 {  
      
        public static void main(String[] args) {  
            // TODO Auto-generated method stub  
            System.out.println(5%1);  
            System.out.println(1%5);  
            System.out.println(2%5);  
            System.out.println(3%5);  
            System.out.println(4%5);  
            System.out.println(5%5);  
            System.out.println(8%-5);  
            System.out.println(-5%9);  
            System.out.println(-18%7);  
            /*
             * 左边小于右边结果是左边,
             * 左边等于右边结果是0
             * 右边等于1结果是0
             *  
             */  
            /*
             *
             * 对于出现负数的情况 看%百分号左边的数字,左边是负数
             * 结果就是负数,左边是正数,结果就是正数,运算方法不变
             */  
      
        }  
      
    }  


输出:

0
1
2
3
4
0
3
-5
-4



[java] view plain copy

    public class Demo2 {  
        public static void main(String[] args){  
            System.out.println("hello word");  
            System.out.println("\"hello word\"");//输出带引号的hello word  
            System.out.println("hello \n word");  
            System.out.println("hello\tword");  
            System.out.println("hello\bword");  
      
      
      
            /*
             * 转义字符:通过  \   反斜杠来转变后面的字母或者符号的含义
             * \n:换行
             * \b:退格
             * \r:回车符号
             * \t:水平跳格符,tab键
             */  
      
        }  
    }  


输出:

hello word
"hello word"
hello
word
hello word
helloword

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马