public class Long
{
   public static void main(String[] args)
      {
      long l=123456789012345l;//java中默认类型为Int型,电脑想要识别长整型需加l(或L)
      System.out.println(l);
       }

2、输出一个单精度的小数常量

public class Float
{
   public static void main(String[] args)
   {  
      float f=2.4f;//小数默认为double型
      System.out.println(f);
   }

3、输出一个布尔类型的变量

 public class L { 

boolean c=true;            
        System.out.println(c);

        c=false;

        System.out.println(c);       

}   

 4、强制类型转换

public class Byte
{
   public static void main(String[] args)
   {
      byte b=5;  //b为byte类型
      b=(byte)(b+200); //200为Int类型,与b类型不一致,要强制转换
      System.out.println(b);
   }

   }

 

5、输出字符型的加法计算

public class T{
   public static void main(String[] args)
   {
        System.out.println((char)('a'+1));
        System.out.println((char)('你'+1));
   }

}

 posted on 2017-10-09 13:48  大鸟3  阅读(84)  评论(0编辑  收藏  举报