This:
String[] strArray = new String[]{
// ...
};
...creates a String array and initializes it with the entries in the {...} part. In your case, there's only one entry.
Why String is created like an object and what does
valueOf(1);
As the documentation will tell you, String.valueOf(int) creates a string representation of the integer value you pass in.
So what that code does is create an array of String with one entry, "1", in it. It's unclear why the author would have written String.valueOf(1) rather than simply "1".
Videos
How do you convert different data types to a string value in SQL?
How do you concatenate string values in SQL?
How do you compare string values in SQL queries?
This:
String[] strArray = new String[]{
// ...
};
...creates a String array and initializes it with the entries in the {...} part. In your case, there's only one entry.
Why String is created like an object and what does
valueOf(1);
As the documentation will tell you, String.valueOf(int) creates a string representation of the integer value you pass in.
So what that code does is create an array of String with one entry, "1", in it. It's unclear why the author would have written String.valueOf(1) rather than simply "1".
String.valueOf(...)
is a method that parses an object or a primitive, and creates a String representation of that object. For example the integer 1 will be converted to the string "1" (as in your example).
String[] strArray = new String[]{
String.valueOf(1)
};
means that we instantiate an array of Strings (basically an array that contains multiple Strings), and we add a String containing "1" in it (see my explanation above).