When declaring a JAVA string array, how do I stabilize the size and declare it?

Asked 2 years ago, Updated 2 years ago, 65 views

For example, determine the size when declaring a string array variable (String[5]), as shown below I have to declare it. String[] apple = new String[5];

But what I need is not an array of strings of a given size 1 character for a specific character, 2 characters for a specific character, etc The size of the arrangement needs to be determined as much as it is put in.

java array string

2022-09-22 18:13

1 Answers

// If the length of "aaa" is greater than 4, the condition may be given as a 5 or 4. trinomial operator.
String s = new String["aaa".length() > 4 ? 5 : 4]


2022-09-22 18:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.