What is the case of using char[] in java? Not the password

Asked 2 years ago, Updated 2 years ago, 41 views

There's a char[] and a string in java Let's use more strings Is it because it's easier? Is there a reason why you don't use char[]?

java string

2022-09-22 20:28

1 Answers

First, String is a class. Char is the primitive type.

And of course, the String is just an array of chars after all. If you look at the actual String source, use char[].

In other words, the String class is intended to make char[] more convenient.

In fact, the more important question is the difference between String a = "abcde"; and String a = new String ("abcde").

In jvm, there is a space called constant pool.

The string is also stored there, and I expected it when it was created as newIt's created in the Shipy Hip.

In other words, objects that are generated as new and that are generated as literal are stored elsewhere.

More precisely, the permanent area. Sometimes, when you run Java programs with many classes such as Eclipse, you may have seen that you are not able to perform it even though you say that you don't have enough permgen memory.


2022-09-22 20:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.