码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA基础学习(6)之使用对象

时间:2019-12-08 01:27:05      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:ann   nbsp   相等   math   can   abd   equals   equal   span   

6使用对象

  • 6.1字符类型
    • 6.1.1字符类型
      • char和int互相转换
      • 1 //a比A大32
        2         Scanner in=new Scanner(System.in);
        3         char c=‘B‘;
        4         char c1=(char)(c+‘a‘-‘A‘);
        5         System.out.println(c1);

         

    • 6.1.2逃逸字符
      • 特殊字符
  • 6.2包裹类型
    • 6.2.1包裹类型
      •   
         1 public static void study25()//6.2.1
         2     {
         3         System.out.println(Integer.MAX_VALUE);
         4         System.out.println(Integer.MIN_VALUE);
         5     }
         6     
         7     public static void study26()//6.2.1
         8     {
         9         System.out.println(Character.isLowerCase(‘a‘));
        10         System.out.println(Character.toLowerCase(‘B‘));
        11     }
        12     
        13     public static void study27()//6.2.1
        14     {
        15         System.out.println(Double.MAX_VALUE);
        16     }
        17     
        18     public static void study28()//6.2.1
        19     {
        20         boolean b=false;
        21         System.out.println(Boolean.toString(b));
        22     }

         

    • 6.2.2Math类
      • abs
      • pow
      • random
      • round
      • 1 System.out.println(Math.abs(-1));
        2         System.out.println(Math.round(11.545));
        3         System.out.println(Math.random());
        4         System.out.println(Math.pow(2, 3.6));

         

  • 6.3字符串
    • 6.3.1字符串变量
      •   
        Scanner in=new Scanner(System.in);
                String s=new String();
        //        s=in.next();//读入一个单词
        //        System.out.println(12+24+s);
                s=in.nextLine();//读入一整行
                System.out.println(s);

         

      • Scanner in=new Scanner(System.in);
                String a=new String("hello");//第一个String对象
                String b=a;//管理对象赋值
                System.out.println(b);
                b="hello";//第二个String对象
                System.out.println(a);
                System.out.println(b);
                System.out.println(a.equals(b));//String相等需要用equals

         

    • 6.3.2字符串操作
      •   
        1 String a="abc";
        2         String b="abd";
        3         
        4         System.out.println(a.compareTo(b));//比较大小
        5         System.out.println(a.charAt(2));//输出指定位置字符
        6         System.out.println("012345".substring(2,4));//输出子字符串
        7         System.out.println("012345".substring(2));
        8         System.out.println("012345".substring(2));

         

JAVA基础学习(6)之使用对象

标签:ann   nbsp   相等   math   can   abd   equals   equal   span   

原文地址:https://www.cnblogs.com/quxiangjia/p/12003957.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!