“Java Array” Kod odpowiedzi

Java Array

String[] animals ={"Dog", "Cat", "Fish", "Turtle", "Penguin"}; // Array of animals
ayaan

Java Array

int[] anas = new int[3];
        age[0] = 1;
        age[1] = 3;
        age[2] = 6;
Prickly Pygmy

Java Array

String[] array = new String[100];
Tired Tiger

Java Array

String[] array = new String[] { "String1", "String2", "String3" }; // Create array
String string3 = array[2]; // Get array
Bredo

Java Array

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars[0]);

// Change elements in array
cars[0] = "Opel";
System.out.println(cars[0]);

// Length of array
System.out.println(cars.length);

// Loop through array
for (int i = 0; i < cars.length; i++) {
  System.out.println(cars[i]);
}
The Cat Coder

Java Array

// 10 Strings in the array named: arr
String[] arr = new String[10];
Karamolegkos

Java Array

class Weight
{
  . . .
  
  public int average()
  {
    . . . 
  }
}

public class WeightTester
{  
  public static void main ( String[] args )
  {
    int[] values = { 98,  99,  98,  99, 100, 101, 102, 100, 104, 105,
                    105, 106, 105, 103, 104, 103, 105, 106, 107, 106,
                    105, 105, 104, 104, 103, 102, 102, 101, 100, 102};
                    
    Weight june = new Weight( values );
    int avg = june.average();
    System.out.println("average = " + avg );
  }
}
brandon alcarmen

Java Array

class Weight
{
  . . .
  
  public int average()
  {
    . . . 
  }
}

public class WeightTester
{  
  public static void main ( String[] args )
  {
    int[] values = { 98,  99,  98,  99, 100, 101, 102, 100, 104, 105,
                    105, 106, 105, 103, 104, 103, 105, 106, 107, 106,
                    105, 105, 104, 104, 103, 102, 102, 101, 100, 102};
                    
    Weight june = new Weight( values );
    int avg = june.average();
    System.out.println("average = " + avg );
  }
}
brandon alcarmen

Odpowiedzi podobne do “Java Array”

Pytania podobne do “Java Array”

Więcej pokrewnych odpowiedzi na “Java Array” w Java

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu