zoukankan      html  css  js  c++  java
  • Java记录参数传递和split

    class Main {
    public static void swap(Integer i, Integer j) {
          Integer temp = new Integer(i);
          i = j;
          j = temp;
       }
       public static void main(String[] args) {
          Integer i = new Integer(10);
          Integer j = new Integer(20);
          swap(i, j);
          System.out.println("i = " + i + ", j = " + j);
       }
    }
      //i = 10, j = 20Java 函数参数通过值传递。
    
    
    class intWrap {
       int x;
    } 
    public class Main { 
        public static void main(String[] args) {
           intWrap i = new intWrap();
           i.x = 10;
           intWrap j = new intWrap();
           j.x = 20;
           swap(i, j);
           System.out.println("i.x = " + i.x + ", j.x = " + j.x);
        } 
        public static void swap(intWrap i, intWrap j) {
           int temp = i.x;
           i.x = j.x;
           j.x = temp;
        }
    }
     // i.x = 20, j.x = 10
    类按引用传递
    class Test
    {
        public void demo(String str)
        {
            String[] arr = str.split(";");//split() 根据指定的规则或分隔符来分隔字符串,并返回数组。
            for (String s : arr)
            {
                System.out.println(s);
            }
        }
     
        public static void main(String[] args)
        {
            char array[] = {'a', 'b', ' ', 'c', 'd', ';', 'e', 'f', ' ', 
                            'g', 'h', ';', 'i', 'j', ' ', 'k', 'l'};
            String str = new String(array);//String 类有一个内置的构造函数 String(character_array),它可以将字符数组初始化成一个字符串
            Test obj = new Test();
            obj.demo(str);
        }
    }
  • 相关阅读:
    芯片产品介绍
    稀疏矩阵理论与实践
    EUV极紫外光刻技术
    国内AI与芯片企业列表
    中国软件外包现状对比
    GPU指令集技术分析
    寒武纪智能系统参数
    TVM量化路线图roadmap
    EUV光刻机市场与技术
    轻松部署 .NET 5 应用程序,这个指南一定不要错过
  • 原文地址:https://www.cnblogs.com/zhuimingzhenbai/p/12692717.html
Copyright © 2011-2022 走看看