Possible Duplicate:
How to create ArrayList (ArrayList<T>) from array (T[]) in Java
I have:
String[] time = {"22:22:22","22:22:23"}; Array asd = null;
How can I put something like asd=time
?
Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. To declare an array, define the variable type with square brackets: String[] cars; We have now declared a variable that holds an array of strings.
Define arrays as SQL variables. Use the ARRAY_AGG built-in function in a cursor declaration, to assign the rows of a single-column result table to elements of an array. Use the cursor to retrieve the array into an SQL out parameter. Use an array constructor to initialize an array.
Put it in a map with count as value. Then simply count strings with count > 1 . Show activity on this post. Convert it to a set.. Then (length_of_Set - length_of_Array) is your count of duplicate elements.
I assume that what you actually need is a java.sql.Array
, since you mention jdbc and setArray
in some of your comments.
Three options:
Connection.createArrayOf()
. This might or might not be available, depending on the JDBC driver you are using.java.sql.Array
. Here is an example for PostgreSQL. The Array
class is not an actual array. Instead it is a helper class that has static methods to help with arrays.
You may be looking to use ArrayList
or something like it. You could use it using List<String> asd = Arrays.asList(time)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With