小编Nul*_*ter的帖子

初始Java堆大小意味着什么?

所以我有一个使用Java堆的程序

-Xms5g -Xmx12g 
Run Code Online (Sandbox Code Playgroud)

我已将初始 Java 堆大小设置为 5GB,最大堆大小设置为 12GB

但是当我查看任务管理器或资源监视器时,我的程序仅使用 400mb。

这是我的问题:

  1. 初始 Java 堆大小意味着什么?
  2. 为什么如果我将初始 Java 堆大小设置为 5GB,我只看到程序的 RAM 使用量为 400MB,难道不应该是 5GB 吗?因为初始堆意味着最小大小,对吗?

java jvm heap-memory

4
推荐指数
1
解决办法
3242
查看次数

主题:未调用 run 方法

我是java新手。有人可以帮助我为什么它不调用 Run 方法。提前致谢。

package com.blt;

public class ThreadExample implements Runnable {
    public static void main(String args[])
    {       

        System.out.println("A");
        Thread T=new Thread();
        System.out.println("B");
        T.setName("Hello");
        System.out.println("C");
        T.start();
        System.out.println("D");
    }

public void run()
{
    System.out.println("Inside run");

}
}
Run Code Online (Sandbox Code Playgroud)

java multithreading

3
推荐指数
1
解决办法
6453
查看次数

java中数组列表的映射

我试图在java中运行这段代码:

List<Map<String , String>> studentList = new ArrayList<>();
Map<String , String> studentRecord = new HashMap();

//Record for first Student
studentRecord.put("Name","aaa");
studentRecord.put("Age","22");
studentRecord.put("Sex","m");
studentList.add(studentRecord);

//Record for second Student
studentRecord.put("Name","bbb");
studentRecord.put("Age","44");
studentRecord.put("Sex","f");
studentList.add(studentRecord);
Run Code Online (Sandbox Code Playgroud)

输出是:

[{Sex=f,Age=44,Name=bbb},{Sex=f,Age=44,Name=bbb}]
Run Code Online (Sandbox Code Playgroud)

代替

 [{Sex=m,Age=22,Name=aaa},{Sex=f,Age=44,Name=bbb}]
Run Code Online (Sandbox Code Playgroud)
  • A。我究竟做错了什么?
  • b. 假设输出是正确的。如何仅打印 StudentList[0] 的“Name”值(表示“aaa”)?

谢谢

java mapping

-1
推荐指数
1
解决办法
2万
查看次数

Colletions.sort()方法未按预期工作

我试图运行一个简单的ArrayList程序.我已经使用collections.sort()了它的方法,但我没有得到输出排序.我使用collections.sort()方法的方式有什么问题吗?

请帮助我找到根本原因.

   import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Vector;

    public class Vector1 {

        public static void main(String args[])
        {
            ArrayList<String> arraylist=new ArrayList<String>();

            arraylist.add("Register.classname");
            arraylist.add("com.jdbc.driver");
            arraylist.add("create Statement");
            arraylist.add("String Sql=Create table hello(column1 Number);");
            arraylist.add("execute Statement");

            Vector<String> vectorlist=new Vector<String>();
            vectorlist.add("Register.classname");
            vectorlist.add("com.jdbc.driver");
            vectorlist.add("create Statement");
            vectorlist.add("String Sql=Create table hello(column1 Number);");
            vectorlist.add("execute Statement");

            Collections.sort(arraylist);
            Collections.sort(vectorlist);

            for(int i=0; i<arraylist.size();i++)
            {
                System.out.println("Arraylist:"+arraylist.get(i));
            }
            for(int j=0;j<arraylist.size();j++)
            {
            System.out.println("Vectorlist:"+vectorlist.get(j));    

            }




        }
    }


    Output:
    Arraylist:Register.classname
    Arraylist:String Sql=Create table hello(column1 Number);
    Arraylist:com.jdbc.driver
    Arraylist:create Statement
    Arraylist:execute Statement
    Vectorlist:Register.classname …
Run Code Online (Sandbox Code Playgroud)

java collections

-3
推荐指数
1
解决办法
444
查看次数

标签 统计

java ×4

collections ×1

heap-memory ×1

jvm ×1

mapping ×1

multithreading ×1