Java-Returning Arrays From Method

Returning Arrays From Method A method may also return an array. For example, in the following program, the method returnData( ) returns an array. Program Program Source class Data { int[] returnData() { return new int[]{20,40,60,80}; } } public class Javaapp { public static void main(String[] args) { Data da = new Data(); int[] getData = da.returnData(); for(int … Read more…

Java-Array

Array So far we have used only the primitive data types, namely char, int, float and double. Although these types are very useful, they are constrained by the fact that a variable of these types can store only one value at any given time. Therefore, they can be used only to handle limited amounts of data. In many applications, however, we … Read more…