[英]Output is not showing second array in this JAVA code
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])
}
我需要在第二個數組中打印數字。
我需要在第二個數組中打印數字。
讓我們從基礎開始,因為我們在這里為您提供幫助,而且您願意學習!!
您只定義了一個數組... int[] Arr所以沒有要打印的第二個數組..
java 中的 arrays 是zero index
,這意味着數組中的第二個元素位於索引號 1 下的插槽中
在您的情況下, Arr[1] 是第二個元素
在 java 中沒有名為Int
的原語,因此您不能聲明
Int foo = 0;
一定是
int foo = 0; //small **i**
任何 java 應用程序的入口點是帶有簽名的 main 方法
public static void main(String[] args)
不是
public static void main()
最后但同樣重要的是:我們在 java 中聲明變量,駝峰式表示,以小字符開頭
所以
int[] Arr = new int [5];
實際上應該是
int[] arr = new int[5];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.