Java derleme xatosi: belgisi topilmadi

Men Java dasturini yozgan edim, lekin xato qilyapman:

ArrayMain.java:13: error: cannot find symbol
            ar[c]=input.nextInt;
                       ^
  symbol:   variable nextInt
  location: variable input of type Scanner

Kod:

import java.util.Scanner;
class ArrayMain
{
    public static void main(String[] args)
    {
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the size:");
        int c=input.nextInt();
        int[] ar=new int[c];
        System.out.println("Enter Element");
        for(int i=0;i0;i--);
        {
            System.out.println(ar[c-1]);
        }
    }
}

Uni qanday tuzataman?

1
Java qo'llanmasini tomosha qilishni va java sintaksisi bilan tanishish uchun java hujjatlarini ko'rishni tavsiya etaman: youtube.com/watch?v=WPvGqX-TXP0
qo'shib qo'ydi muallif Oghli, manba
Java qo'llanmasini tomosha qilishni va java sintaksisi bilan tanishish uchun java hujjatlarini ko'rishni tavsiya etaman: youtube.com/watch?v=WPvGqX-TXP0
qo'shib qo'ydi muallif Oghli, manba

6 javoblar

Bu bo'lishi kerak

 ar[c]=input.nextInt();

shuningdek, usul ta'rifining to'g'ri ekanligiga ishonch hosil qiling

public static void array(int[] ar,int c) {   //notice the removal of semicolon
0
qo'shib qo'ydi

Bu bo'lishi kerak

 ar[c]=input.nextInt();

shuningdek, usul ta'rifining to'g'ri ekanligiga ishonch hosil qiling

public static void array(int[] ar,int c) {   //notice the removal of semicolon
0
qo'shib qo'ydi
ar[c] = input.nextInt;

Noto'g'ri va to'g'ri kod:

ar[c] = input.nextInt(); 
0
qo'shib qo'ydi
ar[c] = input.nextInt;

Noto'g'ri va to'g'ri kod:

ar[c] = input.nextInt(); 
0
qo'shib qo'ydi

ar [c] kodida c o'rniga i katalogini kiritishingiz kerak

System.out.println("Enter Element");
    for(int i=0;i

Shuningdek, array (int [] ar, int c) usulida muammo bo'lishi kerak:

public static void array(int[] ar,int c)//method decleration shouldn't end with `;`
{
    System.out.println("Elements in reverse order are");
   //for loop mustn't end with ';' for(int i=c;i>0;i--);
    for(int i=c-1;i>=0;i--) //start at last element index to the first element which index is i=0
    {
        System.out.println(ar[i]);  //loop over each element in reverse order
    }
}
0
qo'shib qo'ydi

ar [c] kodida c o'rniga i katalogini kiritishingiz kerak

System.out.println("Enter Element");
    for(int i=0;i

Shuningdek, array (int [] ar, int c) usulida muammo bo'lishi kerak:

public static void array(int[] ar,int c)//method decleration shouldn't end with `;`
{
    System.out.println("Elements in reverse order are");
   //for loop mustn't end with ';' for(int i=c;i>0;i--);
    for(int i=c-1;i>=0;i--) //start at last element index to the first element which index is i=0
    {
        System.out.println(ar[i]);  //loop over each element in reverse order
    }
}
0
qo'shib qo'ydi