zoukankan      html  css  js  c++  java
  • 练习题

    //程序员:王智霞

    //1、输出一个长整型的变量

    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;//java中小数默认为double型
          System.out.println(f);
       }
    }

    --------------------------------------------------------------------------------------------------------------------------------------------------------------

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

    public class Boolean
    {
       public static void main(String[] args)
        {
          boolean b=true;
          b=false;
          System.out.println(b);
        }
    }

    -----------------------------------------------------------------------------------------------------------------------------------

    //4、强制类型转换

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

    ----------------------------------------------------------------------------------------------------------------------

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

    public class Char
    {
       public static void main(String[] args)
       {
          System.out.println('c'+1);
          System.out.println((char)('c'+1));//将数字Int类型转换为字符型
       }
    }

    ------------------------------------------------------------------------------------------------------------------------------------

    //6、变量的溢出效果

    public class Overflow
    {
       public static void main(String[] args)
        {
          int big=0x7fffffff;
          System.out.println(big);
         }
    }

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    //7、算数运算符

    import java.util.Scanner;
    public class Count
    {
       public static void main(String[] args)
       {
          Scanner input=new Scanner(System.in);//创一个对象
          System.out.println("输入一个数");
          int x=input.nextInt();//输入一个整型的数
          x=x/1000*1000;
          System.out.println("输出的x为:"+x);   
       }
    }

  • 相关阅读:
    x01.Weiqi.6: 立体棋子
    x01.Game.MapEditor: 地图编辑器
    SQL Server插入中文出现乱码??的解决办法
    Cachecontrol使用:header('Cachecontrol:private')
    验证身份证号码Javascript代码
    .Net GDI+缩放绘图
    Access(JETSQL)问题集锦
    Android开发中Google谷歌地图坐标系怎么转Baidu百度地图坐标系
    21、桥接模式(Bridge模式)详解
    22、装饰模式(装饰设计模式)详解
  • 原文地址:https://www.cnblogs.com/jasonzj/p/7554077.html
Copyright © 2011-2022 走看看