zoukankan      html  css  js  c++  java
  • java数据传递例子+内存分析

    一、引用传递

    1、例子1

    package com.jikexueyuan.ref;
    
    class Ref1{
        int temp = 10;
        
    }
    
    public class RefDemo01 {
        public static void main(String args[]){
            Ref1 r1 =new Ref1();
            r1.temp = 20;
            System.out.println(r1.temp);
            tell(r1);
            System.out.println(r1.temp);
        }
        public static void tell(Ref1 r2){
            r2.temp = 30;
        }
    
    }

    20
    30

    2、例子2
     1 package com.jikexueyuan.ref;
     2 
     3 public class RefDemo02 {
     4 
     5     public static void main(String[] args) {
     6         String str1 = "Hello";
     7         System.out.println(str1);
     8         tell(str1);
     9         System.out.println(str1);
    10     }
    11     public static void tell(String str2){
    12         str2="jike";
    13     }
    14 
    15 }

    Hello
    Hello
    
    
    
    
     1 package com.jikexueyuan.ref;
     2 
     3 class Ref2{
     4     String temp = "hello";
     5 }
     6 
     7 public class RefDemo03 {
     8     public static void main(String args[]){
     9         Ref2  r1 = new Ref2();
    10         r1.temp="jike";
    11         System.out.println(r1.temp);
    12         tell(r1);
    13         System.out.println(r1.temp);
    14     }
    15 
    16     public static void tell(Ref2  r2){
    17         r2.temp="xueyuan";
    18     }
    19 }
    jike
    xueyuan
    
    
    
    
  • 相关阅读:
    图片懒加载原生写法。
    ES6新声明
    下拉刷新上拉加载
    angular动画
    angular路由切换后 轮播以及iscrollJs失效的问题
    ui-route多级嵌套时的默认显示。
    iscroll.js的基本布局
    angular ng-route和ui-route
    require.js JQ
    Cookie&Session
  • 原文地址:https://www.cnblogs.com/linjulin/p/5959458.html
Copyright © 2011-2022 走看看