zoukankan      html  css  js  c++  java
  • jvm理解

    package test;

    import java.lang.*;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class StaticTest2 {

    public static int k = 0;
    // public static StaticTest t1 = new StaticTest("t1"); 类里面的对象放在哪里?是全部在方法区里,还是遵循方法体内的堆栈放置方法?
    // public static StaticTest t2 = new StaticTest("t2");
    {
    print("构造块");
    }
    static{
    print("静态块");
    }
    public static String i = print("i");
    public static int n = 99;
    public String j = print("j");



    // public StaticTest(String str) {
    // System.out.println((++k) + ":" + str + " i=" + i + " n=" + n);
    // ++n;
    // ++i;
    // }

    public static String print(String str) {
    System.out.println(str);
    return str;
    }
    public String meth(String str) {
    String a = "123"; //a放到栈里面,123放到堆里
    StaticTest2 b= new StaticTest2();   //b对象的引用放到栈里面,b对象的
    //实例数据放到堆里(不包括b对象所属类的类信息,类信息放到方法区里面
    b.j = "456";   //b对象的j属性值是否放到堆里?

    return str;
    }
    public static void main(String[] args) {
    StaticTest2 r= new StaticTest2();
    StaticTest2 t = new StaticTest2();
    }

    }

  • 相关阅读:
    DockerFile构建步骤及命令
    linux安装nginx及常用命令
    docker常用命令
    Docker安装
    获取TrustedInstaller权限
    获取本机公网ip的url地址
    centOS7配置ip
    VS Code配置c语言环境
    Linux l 2.4.20-8 # 溢出
    VMware Destination Host Unreachable
  • 原文地址:https://www.cnblogs.com/jichen/p/8567060.html
Copyright © 2011-2022 走看看