zoukankan      html  css  js  c++  java
  • 数组,字符串,

    一、数组:
        // [1,1,1,1,1]
       相同类型的多个对象,
       引用类型
       所有的类
       所有的接口
       所有的数组
       length

        int[] ints = new int[3];
        new:指的是在内存空间重新开辟一块区域
       String s = "sdfgdsfgsd";
       String s = new String("sdfgdsfgsd");

    二、包装类:
           Integer.parseInt();

           byte---Byte
           short---Short
           int---Integer
           long---Long

           float---Float
          double---Double

          boolean---Boolean

          char---Character

    public class Shuzu
    {
          public static void main(String[] args)
         {
                  /*String s1="abc";
                   String s2="abc";
                   System.out.println(s1==s2);
                   // true
                  String s3 = new String("abc");
                  String s4 = new String("abc");
                  System.out.println(s3==s4);
                  // System.out.println(s3.equals(s4));
                  // false

                   int a = 5;
                   int b = 5;
                   int[] a = new int[5];
                   // int b[] = new int[5];
                  for(int i=0;i<a.length;i++){
                  System.out.println(a[i]);
                   }*/

                /* System.out.println(Integer.MIN_VALUE);
                System.out.println(Integer.MAX_VALUE);
                System.out.println(Byte.MIN_VALUE);
                System.out.println(Byte.MAX_VALUE);
                System.out.println(Long.MIN_VALUE);
                System.out.println(Long.MAX_VALUE);
                System.out.println(Short.MIN_VALUE);
                System.out.println(Short.MAX_VALUE);

                System.out.println(Float.MIN_VALUE);
                System.out.println(Float.MAX_VALUE);
                System.out.println(Double.MIN_VALUE);
                System.out.println(Double.MAX_VALUE);

                System.out.println(Float.parseFloat("12.34"));
                System.out.println("====================");
                System.out.println(Float.valueOf("12"));*/

                 // 字符串的处理
                 String str = " a new world a NEW start ";
                 /*System.out.println(str.length()); // 返回整个字符串的长度


                 System.out.println(str.trim()); //去掉字符串两边的空格


                 System.out.println(str.trim().length()); //返回去掉两边空格后整个字符串长度


                 System.out.println(str.charAt(5)); //取出字符串中制定索引位置的字符(从0开始)


                 System.out.println(str.contains("abc"));//判断一个字符串是否包含另一个字符串


                 System.out.println(str.startsWith("qq"));//判断一个字符串是否以另一个字符串开头
                 System.out.println(str.endsWith("qq"));//判断一个字符串是否以另一个字符串结尾


                 System.out.println(str.replace('a','b'));
                 System.out.println(str.replace("new","old"));//替换字符串中指定的字符或字符串


                 String[] strs =str.split(" ");
                 System.out.println(strs.length);
                 for(String s: strs){
                           System.out.println(s);
                 }*/
                /*for(var p in obj){
                           alert(obj[p]);
                }*/


                System.out.println(str.toUpperCase());//将字符串转换成大写
                System.out.println(str.toLowerCase());//将字符串转换成小写


                System.out.println(String.valueOf(6));
                System.out.println(str.indexOf("new"));//子字符串在字符串中第一次出现的位置
                System.out.println(str.lastIndexOf("new"));//子字符串在字符串中最后一次出现的位置


                System.out.println(str.substring(5)); //截取字符串
                System.out.println(str.substring(5,8));



              }
    }

  • 相关阅读:
    [写代码]处理一组lrc歌词文件
    [ubuntu]windows重装以后,恢复grub引导
    [HDOJ1878]欧拉回路
    [写代码]解析自定义数据库文件的思路
    [写代码]wordList——百词斩CLI版
    [HDOJ2544]最短路
    [HDOJ1285] 确定比赛名次
    [HDOJ1232]畅通工程
    [HDOJ2717]Catch That Cow
    jQuery实现点击开关图片切换
  • 原文地址:https://www.cnblogs.com/jgjk/p/7182449.html
Copyright © 2011-2022 走看看