Answers for "java array definition"

35

array in java

//method 1
int[] age = new int[3];
        age[0] = 1;
        age[1] = 3;
        age[2] = 6;

        for (int i=0; i < 3; i++)
            System.out.println(age[i]);

//method 2
        int[] num = {3,3,5};
        //int num[] = {3,3,5}; also works the same

        System.out.println(num[0]);
Posted by: Guest on April-30-2020
35

array in java

//method 1
int[] age = new int[3];
        age[0] = 1;
        age[1] = 3;
        age[2] = 6;

        for (int i=0; i < 3; i++)
            System.out.println(age[i]);

//method 2
        int[] num = {3,3,5};
        //int num[] = {3,3,5}; also works the same

        System.out.println(num[0]);
Posted by: Guest on April-30-2020
5

java array

String[] cars = new String[4];
cars[0] = "Volvo";
cars[1] = "BMW";
cars[2] = "Ford";
cars[3] = "Mazda";
Posted by: Guest on February-05-2021
5

java array

String[] cars = new String[4];
cars[0] = "Volvo";
cars[1] = "BMW";
cars[2] = "Ford";
cars[3] = "Mazda";
Posted by: Guest on February-05-2021
10

array java

int[] intArray = new int[20];
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
Posted by: Guest on April-29-2020
10

array java

int[] intArray = new int[20];
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
Posted by: Guest on April-29-2020
3

array in java

int[] storer = {10,85,62};
System.out.println(storer[0]);
Posted by: Guest on April-06-2021
3

array in java

int[] storer = {10,85,62};
System.out.println(storer[0]);
Posted by: Guest on April-06-2021
5

array in java

Size is fixed
It supports both primitives and objects
Can be also multi-dimensional
Posted by: Guest on January-05-2021
5

array in java

Size is fixed
It supports both primitives and objects
Can be also multi-dimensional
Posted by: Guest on January-05-2021
0

Java Arrays

public class Test {

   public static void main(String args[]) {
      int [] numbers = {10, 20, 30, 40, 50};

      for(int x : numbers ) {
         System.out.print( x );
         System.out.print(",");
      }
      System.out.print("\n");
      String [] names = {"James", "Larry", "Tom", "Lacy"};

      for( String name : names ) {
         System.out.print( name );
         System.out.print(",");
      }
   }
}
Posted by: Guest on August-31-2021
0

Java Arrays

public class Test {

   public static void main(String args[]) {
      int [] numbers = {10, 20, 30, 40, 50};

      for(int x : numbers ) {
         System.out.print( x );
         System.out.print(",");
      }
      System.out.print("\n");
      String [] names = {"James", "Larry", "Tom", "Lacy"};

      for( String name : names ) {
         System.out.print( name );
         System.out.print(",");
      }
   }
}
Posted by: Guest on August-31-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language