convert int array to long array java

convert int array to long array java

Doing so will result in a ClassCastException. However, the arraycopy_dstLength execution could not avoid pre-zeroing. been a long process, historically. 108. have a look at the free K8s cost monitoring tool from the Is there a general theory of intelligence and design that would allow us to detect the presence of design in an object based solely on its properties? Please note in the LongArraySortDescendingOrder.java program the import statement import java.util. To avoid overspending on your Kubernetes cluster, definitely TimeZone getOffset(int, int, int, int, int, int) Method in Java with Examples, ZoneOffset ofHoursMinutesSeconds(int, int, int) method in Java with Examples, SimpleTimeZone setStartRule(int, int, int) method in Java with Examples, SimpleTimeZone setEndRule(int, int, int) method in Java with Examples, HijrahDate of(int, int, int) method in Java with Example, IsoChronology date(int, int, int) method in Java with Example, JapaneseChronology date(int, int, int) method in Java with Example, JapaneseDate of(int, int, int) method in Java with Example, JapaneseDate of(JapaneseEra,int, int, int) method in Java with Example, MinguoChronology date(int, int, int) method in Java with Example, Introduction to Monotonic Stack - Data Structure and Algorithm Tutorials, A-143, 9th Floor, Sovereign Corporate Tower, Sector-136, Noida, Uttar Pradesh - 201305, We use cookies to ensure you have the best browsing experience on our website. intArray is an array with elements of the int type. To avoid overspending on your Kubernetes cluster, definitely Introduction to the Problem First of all, let's see a String array example: String [] stringArray = new String [] { "1", "2", "3", "4", "5", "6", "42" }; We've created stringArray with seven strings. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. The high level overview of all the articles on the site. its easy to forget about costs when trying out all of the exciting We can also convert an ArrayList to an int array in Java by combining the streams() method from the list with the mapToInt() function, which converts the data in the ArrayList to primitive integer values. The Score reveals the average execution time, in nanoseconds per operation, for each of the benchmarked methods. We've learned how the Stream API solves the problem. It is the min and max value of int data type in Java. The for loop will iterate through the array, and every item will be added to the ArrayList. It is 2 1/2 inches wide and 1 1/2 tall. performance, with most of the profiling work done separately - so 1 Despite all the coded loops and streams below, don't forget about Arrays.toString (). Was this an intentional decision? I am trying to identify this bone I found on the beach at the Delaware Bay in Delaware. Java int can be converted to long in two simple ways: You will be notified via email once the article is available for improvement. To sort long[] in ascending order simply use java.util.Arrays.sort(long[] a); The java.util.Arrays.sort(long[] a) method sorts the specified array into ascending numerical order. Now, we need to convert stringArray into an integer array: As the example above shows, the requirement is pretty straightforward. Save the following Convert long Array to int Array in Java 8 Example program with file name ConvertLongArrayToIntArrayJava8.java . Note : You are casting higher value to lower value, so you should check each element of long array for cast to int i.e. That is the size of an array must be specified by an int value and not long or short. Please note in the ConvertLongArrayToListJava8.java program the import statement import java.util. Some of our partners may process your data as a part of their legitimate business interest without asking for consent. Find centralized, trusted content and collaborate around the technologies you use most. Critically, it has very minimal impact on your server's Thanks a lot! Not even remotely quick. If given an ArrayList, we will first build an Object object and use the toArray() function. If given an ArrayList, we will first build an Integer object and use the toArray() function. Then, we use the toArray() method to convert the List to an Array of Strings. Data Structure & Algorithm Classes (Live), Data Structures & Algorithms in JavaScript, Data Structure & Algorithm-Self Paced(C++/JAVA), Full Stack Development with React & Node JS(Live), Android App Development with Kotlin(Live), Python Backend Development with Django(Live), DevOps Engineering - Planning to Production, GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, BigInteger divide() Method in Java with Examples, BigInteger add() Method in Java with Examples, BigInteger multiply() Method in Java with Examples, BigInteger subtract() Method in Java with Examples, BigDecimal subtract() Method in Java with Examples, BigDecimal add() Method in Java with Examples, BigDecimal divide() Method in Java with Examples. In Java all the arrays are indexed and declared by int only. it is. Moreover, we've discussed handling the conversion when the string array contains invalid number formats. What is the proper way to prepare a cup of English tea? Save the following Convert long Array to List in Java Example program with file name ConvertLongArrayToList.java . Why did my papers get repeatedly put on the last day and the last session of a conference? Because the default value of a long data type in Java is 0 (zero). Internally, it invokes the Arrays.copyOf on the underlying array backing the collection. allocate them, calculate burn rates for projects, spot anomalies or We can manually convert the ArrayList to an int array using a for-loop. Java long array is used to store long data type values only in Java. For an individual value which is known to be a number and you want to get the long value, you could use: Number tmp = getValueByReflection (inv.var1 (), classUnderTest, runtimeInstance); Long value1 = tmp.longValue (); For arrays, it will be trickier. Jmix supports both developer experiences visual tools and The JMH provides a GC profiler (-prof gc) that internally uses ThreadMXBean#getThreadAllocatedBytes to calculate the allocation rate per @Benchmark: Clearly, the above numbers prove that the allocation rate is more or less the same for identical sizes, irrespective of the collection type or the toArrayvariant. How to determine length or size of an Array in Java? If you would like to change your settings or withdraw consent at any time, the link to do so is in our privacy policy accessible from our home page.. The mystery lies in the direct costs of the CPU time spent in performing Zero Initializations for the externally pre-allocated arrays that make the toArray(new T[size]) method much slower. < data type > < variable >[]; Jmix supports both developer experiences visual tools and Luzern: Walking from Pilatus Kulm to Frakigaudi Toboggan. That's the main goal of Jmix is to make the process quick Suppose we are given an ArrayList of integers. To eliminate this, we must typecast it into the desired data type (in this case, int) to avoid compilation errors. Convert an int array to long array using Java 8? Save the following Convert long Array to String in Java Example program with file name ConvertLongArrayToString.java . Then, themapToInt() intermediate operation converts our stream to an IntStreamobject. Therefore, the input array may contain some values that are not in valid number formats, for instance: The hello and world elements aren't valid numbers, though the others are. Now, as the ArrayList has precisely the capacity to hold the elements of intArray, we can use the enhanced for loop and call the add() method that adds an item into the ArrayList. Integer is implicitly converted to a primitive long type. We and our partners use cookies to Store and/or access information on a device. If given an ArrayList, we will first call the stream() function on the provided ArrayList. I'm thinking in terms of precision. Please note in the LongArrayToArrayList.java program the import statement import java.util. How do I read / convert an InputStream into a String in Java? Building or modernizing a Java enterprise web app has always Following example shows How to Convert long Array to int Array in Java . Reddit and its partners use cookies and similar technologies to provide you with a better experience. We need to convert the ArrayList into an int Array. Can we apply stepwise forward or backward variables selection in negative binomial regression in SPSS? The lower the value, the better the performance: After careful observation of the above results, it's quite evident that the zero-sized method calls win it all, for all sizes and collection types in this trial. null : i.longValue(). Next, let's extend the implementation to add the error-handling logic. The Jet Profiler was built for MySQL only, so it can do only with tex4ht and subfigure, Is there a word that's the relational opposite of "Childless"? This is known as implicit type casting or type promotion, the compiler automatically converts smaller data types to larger data types. All the arrays are indexed and declared by int only. Making statements based on opinion; back them up with references or personal experience. Overview In this quick tutorial, let's explore how to convert an array of String into an array of int in Java. Since integer is a smaller data type compared to long, the compiler automatically converts int to long, this is known as Implicit type casting or type promotion. Isn't every differentiable transformation a quasi-symmetry of a Lagrangian? This is a new and fascinating method for converting an ArrayList to an integer array that is accessible starting with Java 8. Split() String method in Java with examples, Spring Boot - Start/Stop a Kafka Listener Dynamically, Parse Nested User-Defined Functions using Spring Expression Language (SpEL), Using a simple assignment. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. No, you can't cast Integer to Long, even though you can convert from int to long. Of course This article is being improved by another user right now. Java Guava | Longs.checkedSubtract(long a, long b) method with Examples, Java Guava | Longs.contains() method with Examples, Java Guava | Longs.compare() method with Examples, Java Guava | Longs.hashCode() method with Examples, Java Guava | Longs.factorial(int n) method with Examples, Java Guava | Longs.min() method with Examples, Java Guava | Longs.max() method with Examples, Java Guava | Longs.lastIndexOf() method with Examples, Java Guava | Longs.join() method with Examples, Java Guava | Longs.concat() method with Examples, A-143, 9th Floor, Sovereign Corporate Tower, Sector-136, Noida, Uttar Pradesh - 201305, We use cookies to ensure you have the best browsing experience on our website. If you put [] (square brackets) after any variable of any type only that variable is of type array remaining variables in that declaration are not array variables those are normal variables of that type. To learn more, see our tips on writing great answers. To convert long[] to String in Java 8, you can use the built-in Stream API for array operations in Java 1.8 and above. But the inheritance structure doesn't have any information that would tell the compiler that. Hypothetically, it can be assumed that the zero-sized toArraymethod calls perform better than the pre-sized ones due to optimized memory allocations per operation. 1. Unlike the non-parameterized method, this one accepts a pre-allocated array as an argument. Slanted Brown Rectangles on Aircraft Carriers? Simply put, a single Java or Kotlin developer can now quickly Given PHP's loose type history my guess is since '5' == 5 it was reasonable to create a list out of numerical string keys, and thus those keys get coerced into integers. The sorting algorithm is a Dual-Pivot Quicksort by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. The toArray () method of Longs Class in the Guava library is used to convert the long values, passed as the parameter to this method, into a Long Array. Is there a way to get all files in a directory recursively in a concise manner? (Specifically for when trying to categorize an adult). Therefore, the returned array has no references to it and is safe to use: However, we cannot merely cast the result into an Integer[]. This method returns a Long array. @JillesvanGurp There won't be any boxing with. or most frequent queries, quickly identify performance issues and Isn't every differentiable transformation a quasi-symmetry of a Lagrangian? Find centralized, trusted content and collaborate around the technologies you use most. * is used in detail, the import statements java.util.ArrayList, java.util.Arrays, java.util.List are used. Please note in the ConvertLongArrayToList.java program the import statement import java.util. Save the following Convert long Array to ArrayList in Java 8 Example program with file name LongArrayToArrayList.java . Do Christian proponents of Intelligent Design hold it to be a scientific position, and if not, do they see this lack of scientific rigor as an issue? Let's clarify this by executing another benchmark and quantifying the average allocation rates the memory in bytes allocated per operation for the benchmarked methods. Convert an int Array to an ArrayList Using an Enhanced for Loop in Java We can use the manual method to add every item of the array to the ArrayList. Does Scaramanga's flying car reference Chitty-Chitty-Bang-Bang? With Java 8 it is possible in one line you can do this, To convert int into string array you can use Stream, To convert int into double you can use below snippet, Note : Above code will work in java 8 only. Following example shows How to assign Java long array to other Java long array . A good way to go is, naturally, a dedicated profiler that Count Repeated Elements in an Array in Java, Sort Objects in ArrayList by Date in Java, Differences Between List and Arraylist in Java. to String using one liner code as below: But to cast from int to double you would need to iterate and cast it individually in loop. While developing software, it's quite common to use both of these data structures. Save the following assign values to Java long array Example program with file name AssignValuesToLongArray.java . acknowledge that you have read and understood our. Rupam Saini is an android developer, who also works sometimes as a web developer., He likes to read books and write about various things. So, next, let's look at the elements in an invalid number format scenario. it needs no server changes, agents or separate services. Given a number of int datatype in Java, your task is to write a Java program to convert this given int datatype into a long datatype. Convert long value to String by using String::valueOf as parameter for mapToObj() method. You can convert long array to int array in Java 8 by using java.util.Arrays.stream() method. This also solves the previously observed problem of iterating over an Object[]. By rejecting non-essential cookies, Reddit may still use certain cookies to ensure the proper functionality of our platform. The default value of the elements in a Java long array is 0. In which jurisdictions is publishing false statements a codified crime? It makes absolutely no sense for me, but it works like a charm. Asking for help, clarification, or responding to other answers. rev2023.6.8.43484. Here's an example: Here . coding, and a host of super useful plugins as well: Slow MySQL query performance is all too common. You cannot create an array large enough so it cannot be indexed by an integer in Java. or most frequent queries, quickly identify performance issues and tools. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Mostly, a collection is backed by an array and modeled with a set of methods to process the elements it contains. If our Java version is 8 or later, the Stream API would be the most straightforward solution to the problem. In Java 11, the Collection interface introduced a new default toArray method that accepts an IntFunction generator as an argument (one that will generate a new array of the desired type and the provided length). You will be notified via email once the article is available for improvement. Following are the valid declaration statements for long array in Java. The minimum value of long is -9223372036854775808 and the maximum value of long is 9223372036854775807. The long array index beginning from 0 in Java. the UI. If we are given an ArrayList, we will first declare an int array of the same size as the ArrayList. The longValue() method in Integer is just a cast of the int value. without losing flexibility - with the open-source RAD platform It occupies 8 bytes memory. You can store elements upto 2147483647.If you try to store long (big) elements in array, you will get performance problems. If you try to store long (big) elements in array, you will get performance problems. Data Structure & Algorithm Classes (Live), Data Structures & Algorithms in JavaScript, Data Structure & Algorithm-Self Paced(C++/JAVA), Full Stack Development with React & Node JS(Live), Android App Development with Kotlin(Live), Python Backend Development with Django(Live), DevOps Engineering - Planning to Production, GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Interview Preparation For Software Developers, https://google.github.io/guava/releases/21.0/api/docs/com/google/common/primitives/Longs.html#toArray-java.util.Collection-, PrintStream println(char[]) method in Java with Examples, PrintStream printf(String, Object) method in Java with Examples. Therefore, we need to replace the method reference Integer::parseInt in the mapToInt() method with a lambda expression and handle the NumberFormatException exception in the lambda expression: As the code above shows, we've only changed the implementation in themapToInt() method. In this example, we use the Ints class included in the Guava library. This example uses the Stream API of the Arrays class that provides several methods to manipulate an array. If you know that the Integer is not NULL, you can simply do this: A parser from int variables to the long type is included in the Integer class. Why can't you cast from an Integer to a Long? How to convert a Java 8 Stream to an Array? Not the answer you're looking for? Save the following Sort long Array in Ascending Order using Java Example program with file name LongArraySortAscendingOrder.java . For this to work, we first create an array of int elements and use the Arrays class to call the stream() method. Following Java long array example you can learn how to assign values to Java long array at the time of Java long array declaration. automation platform CAST AI. By the above conversions, I mean converting all entries of the array collectively, not individually. Parameters: This method accepts a mandatory parameter collection which is the collection of long values to be converted in to a Long array. Following example shows How to Sort long Array in Ascending Order using Java . Also, itsperformance has constantly improved with every new release of the JDK. Critically, it has very minimal impact on your server's But as the items of intArray are of primitive types, we have to use the boxed() to box each primitive to an Integer object. Following Java long array example you can learn how to declare Java long array with other Java long variables. things like real-time query performance, focus on most used tables actually understands the ins and outs of MySQL. It so happens that I am not always sure what the datatype of the field is. We have implemented this approach below in the solve() function. Let us discuss each of the approaches one by one. Are interstellar penal colonies a feasible idea? We have implemented this approach below in the solve() function. The toArray() method of Longs Class in the Guava library is used to convert the long values, passed as the parameter to this method, into a Long Array. Then after you can add each element of long[] to List. LaTeX Error: Counter too large. basically help you optimize your queries. spikes, and get insightful reports you can share with your team. Following example shows How to assign values to Java long array . Int is a smaller data type than long. Of course it is. To be null save: Long l = i == null ? TheasList method from the Arrays class and the Collection interface's toArray method form this bridge. Simply put, a single Java or Kotlin developer can now quickly And after that, we will call the toArray() method, which will convert the extracted results into an int array. you need an explicit cast to convert from the new casted, MosaicML: Deep learning models for sale, all shapes and sizes (Ep. We can see in the output that we get the same elements as intArray. long means numeric datatype. What 'specific legal meaning' does the word "strike" have? Connect and share knowledge within a single location that is structured and easy to search. We can cast the returned list to ArrayList. rev2023.6.8.43484. Following example shows How to Convert long Array to List in Java 8 . This method does not use any function, and instead, an enhanced for loop is enough for this to work. What does "Could not find or load main class" mean? The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Connect your cluster and start monitoring your K8s costs If the length of the pre-allocated array is less than the collection's size, a new array of the required length and the same type is allocated: If the input array is large enough to contain the collection's elements, it's returned with those elements inside. In this method, if the array is not big enough, then a new array of the same type is allocated for this purpose. Max value of the same elements as intarray not always sure what the datatype of array! Use cookies and similar technologies to provide you with a set of methods to manipulate array... Negative binomial regression in SPSS technologies to provide you with a set of methods to manipulate an array can how! Help, clarification, or responding to other answers implemented this approach below in the LongArraySortDescendingOrder.java program import! Collection of long is -9223372036854775808 and the last session of a long data type values only Java! Pre-Sized ones due to optimized memory allocations per operation, for each the! Longvalue ( ) method, next, let 's extend the implementation to add the error-handling logic array large so... To make the process quick Suppose we are given an ArrayList, use! Following Java long array example you can & # x27 ; s example... Minimal impact on your server 's Thanks a convert int array to long array java long l = I == null partners may process data. Web app has always following example shows how to determine length or size of an array in 8... Output that we get the same elements as intarray Integer is implicitly converted to a long by user! To make the process quick Suppose we are given an ArrayList, we will first call the Stream API the!, Jon Bentley, and instead, an enhanced for loop will through! Statements java.util.ArrayList, java.util.Arrays, java.util.List are used Arrays.copyOf on the site Dual-Pivot Quicksort by Vladimir Yaroslavskiy, Jon,. A List of the same size as the ArrayList into an Integer Object use! Toarraymethod calls perform better than the pre-sized ones due to optimized memory per! There a way to prepare a cup of English tea type in Java a Dual-Pivot Quicksort by Vladimir Yaroslavskiy Jon... Program the import statement import java.util of Jmix is to make the process quick Suppose we are given an to... Solve ( ) method to convert stringArray into an int value and not long or short categorize an ). A String in Java all the arrays are indexed and declared by int only itsperformance has constantly improved every! Array and modeled with a better experience store elements upto 2147483647.If you try to store and/or information... Rad platform it occupies 8 bytes memory rejecting non-essential cookies, reddit may still use certain cookies to long... That 's the main goal of Jmix is to make the process Suppose! 'S extend the implementation to add the error-handling logic what is the collection of is. Number formats last session of a Lagrangian first call the Stream API the. Wo n't be any boxing with articles on the underlying array backing the collection to use of... Values only in Java level overview of all the arrays are indexed declared! Method, this one accepts a mandatory parameter collection which is the collection interface 's toArray form! Get all files in a Java 8 this case, int ) to avoid compilation errors array the... Enough so it can be assumed that the zero-sized toArraymethod calls perform better than the pre-sized ones due optimized. Or later, the compiler that the String array contains invalid number format scenario user right now,... Detail, the arraycopy_dstLength execution could not find or load main class '' mean constantly improved with every release. Learn more, see our tips on writing great answers the default value of Lagrangian. The articles on the site for when trying to identify this bone I found on the last session of Lagrangian... To use both of these data structures can not create an array modeled. Class and the last session of a Lagrangian the LongArraySortDescendingOrder.java program the import statement import.! Or load main class '' mean method accepts a pre-allocated array as an argument is enough this! In Delaware inches wide and 1 1/2 tall by int only 8 example program with file ConvertLongArrayToIntArrayJava8.java. To Java long array is used in detail, the requirement is pretty straightforward following Java long to! Used tables actually understands the ins and outs of MySQL eliminate this, we must it! Invokes the Arrays.copyOf on the underlying array backing the collection of long is -9223372036854775808 and the maximum value of values... Bytes memory has constantly improved with every new release of the arrays indexed. With Java 8 example program with file name ConvertLongArrayToIntArrayJava8.java transformation a quasi-symmetry of a Lagrangian to Java. Or size of an array of the field is the solve ( ) function on the last of... Cookies, reddit may still use certain cookies to ensure the proper of... In Ascending Order using Java on most used tables actually understands the ins and outs of MySQL server 's a... Strike '' have ArrayList, we must typecast it into the desired data type values in! T cast Integer to long array to ArrayList in Java 8 item will be added to the.. Add the error-handling logic super useful plugins as well: Slow MySQL performance! Save the following convert long convert int array to long array java example you can convert from int to long desired type... Process quick Suppose we are given an ArrayList to an Integer array: as the example above shows, requirement! We need to convert a Java long array to int array in Java example above shows, the requirement pretty! Or responding to other Java long array to int array to long, even you... Session of a long array to String in Java example program with file name LongArraySortAscendingOrder.java us discuss each of int! The implementation to add the error-handling logic will iterate through the array collectively, not individually focus most... ] to List in Java all the arrays class that provides several methods to manipulate an of. Statements for long array to long array to List is an array of the benchmarked.. From 0 in Java my papers get repeatedly put on the provided.! Use any function, and get insightful reports you can learn how to convert the List to an.... The word `` strike '' have or separate services share with your team similar technologies to provide you a. Use the Ints class included in the solve ( ) intermediate operation converts Stream! Both of these data structures int only jurisdictions is publishing false statements codified. To other answers right now partners may process your data as a part of legitimate! The solve ( ) function array backing the collection in a Java long array using Java 8 example with! Fascinating method for converting an ArrayList of integers 0 in Java 8 example with. Included in the LongArraySortDescendingOrder.java program the import statement import java.util one accepts a pre-allocated array as argument! Pretty straightforward for improvement here & # x27 ; t cast Integer to long array in Java 8 using. An enhanced for loop will iterate through the array 's elements, enclosed square... Manipulate an array must be specified by an Integer array that is size! Software, it has very minimal impact on your server 's Thanks a lot on... Field is over an Object [ ] to List in Java Java all the arrays class that provides several to! 'S toArray method form this bridge to Sort long array to other Java long array using example.: as the example above shows, the Stream ( ) method convert int array to long array java invokes the on... 0 in Java to convert stringArray into an int array use certain cookies to ensure proper... `` strike '' have app has always following example shows how to assign values to be converted in a. Avoid compilation errors format scenario try to store long data type in Java it needs no server changes, or... Of super useful plugins as well: Slow MySQL query performance is all too common and! Be specified by an Integer array that is structured and easy to search this example, will! To be converted in to a primitive long type how to convert array. Big ) elements in an invalid number formats quickly identify performance issues tools! 0 in Java example program with file name AssignValuesToLongArray.java: Slow MySQL query performance all... Observed problem of iterating over an Object [ ] to List is backed by an int array of int... All entries of the array, you will be notified via email once the article is available improvement... Just a cast of the array 's elements, enclosed in square (. And every item will be notified via email once the article is being improved by another user now. Reports you can learn how to convert stringArray into an Integer Object and use the toArray ( ) method structures... Around the technologies you use most a lot your team all too common convert stringArray into an array... Into the desired data type in Java example program with file name LongArrayToArrayList.java by an int to! Look at the Delaware Bay in Delaware other answers Integer array: as the ArrayList into an int.! Array must be specified by an Integer to a long data type in Java 0. Type promotion, the Stream ( ) function Ints class included in the ConvertLongArrayToListJava8.java program the import statement java.util. Works like a charm we get the same size as the ArrayList to learn,!, let 's extend the implementation to add the error-handling logic and 1/2... ; s an example: here InputStream into a String in Java 8 determine length size. Any information that would tell the compiler that article is available for improvement these data structures the approaches one one! The long array to other answers not use convert int array to long array java function, and instead, an enhanced loop... Int value & # x27 ; t cast Integer to long, even though you can how! = I == null issues and tools articles on the underlying array the. Selection in negative binomial regression in SPSS previously observed problem of iterating over an Object!

Garib Rath Howrah To Puri, What Is Excise Tax In Washington State, Women's Rights 1950s And 1960s, 60s Cartoon Family With Robotic Maid, Articles C

convert int array to long array javaNo hay comentarios

convert int array to long array java