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;//小数默认为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));
       }

    }

    6、变量的溢出效果

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

    7、算数运算符
    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);   
       }

  • 相关阅读:
    C++11并发之std::thread<转>
    YUV420格式解析<转>
    在windows、linux中开启nginx的Gzip压缩大大提高页面、图片加载速度<转>
    curl 超时设置<转>
    C++中map用法详解《转》
    同一台服务器配置多个tomcat服务的方法
    找出两个排好序的数组的中位数
    mysql中设置默认字符编码为utf-8
    大步小步攻击算法_完全版
    ACL登陆认证
  • 原文地址:https://www.cnblogs.com/kongtingting/p/7615957.html
Copyright © 2011-2022 走看看