public class Main {
public static void main()
Int[] Arr = new int [5];
Arr[0] = 1;
Arr[1] = 2;
Arr[2] = 6;
Arr[3] = 11;
Arr[4] = 8;{
System.out.println(Arr[2])
}
I need to print number in the second array.
I need to print number in the second array.
lets start with the basics coz we are here to help and you are willing to learn!!
you have defined only one array... int[] Arr so there is no 2nd array to be printed..
arrays in java are zero index
, means the 2nd element in your array is located at the slot under the index number 1
in your case Arr[1] is the 2nd element tho
in java there is no such primitive named Int
so you can not declare
Int foo = 0;
must be
int foo = 0; //small **i**
the entry point of any java application is the main method with the signature
public static void main(String[] args)
not
public static void main()
last but not least: we declare variables in java camel-case means, beginning with small character
therefore
int[] Arr = new int [5];
should be actually
int[] arr = new int[5];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.