Vitajte na [www.pocitac.win] Pripojiť k domovskej stránke Obľúbené stránky
Vytvorte novú triedu s názvom " test " . V textovom editore , zadajte nasledujúci kód : .
Public class testovacie {
}
2
Vytvoriť pole
Otestujte public class {
public static void main ( String [ ] args ) {
int [ ] = { 1,2,3,4,5 testarray } ;
}
}
vytvorí pole obývaný s číslami jedna až päť .
3
Zmeňte obsah poľa . V textovom editore , pridajte nasledujúci kód :
public class testovacie {
public static void main ( String [ ] args ) {
int [ ] testarray = { 1 , 2,3,4,5 } ;
System.out.println ( testarray [ 0 ] ) ;
testarray [ 0 ] = 11 ;
System.out . println ( testarray [ 0 ] ) ;
}
}
vypíše obsah prvku na indexe 0 , meniť obsah z " 1 " na " 11 " a potom znovu na výstupe obsah prvku na indexe 0.