Ask your own question, for FREE!
Computer Science 27 Online
OpenStudy (anonymous):

please help me!!!!! the question in attachment

OpenStudy (anonymous):

OpenStudy (anonymous):

what the wrong ? import java.util.Scanner; public class Task2 { public static void main(String [] args){ Scanner input = new Scanner(System.in); System.out.println(" Size of Array : "); int in=input.nextInt(); int List[]= new int [size]; } public static boolean isSorted(int[] list){ boolean sorted = true; for (int i = 1; i < list.size(); i++) { if (list.get(i-1).compareTo(list.get(i)) != 1) sorted = false; } return sorted; } } }}

OpenStudy (anonymous):

Without actually testing it, I can see that you have "int List[]= new int [size];" Note that you do not have a "size" variable :) You need to use the "in" variable which the user input first. After that, you also need to ask for the other numbers which the user will enter. You could create an for loop which will get "in"-number of variables that the user has typed in. To help you further, you should provide the error message you get when you run the program.

OpenStudy (anonymous):

here the error message which i get

OpenStudy (anonymous):

Change the [size] to [in]. To find out what is wrong with your program, you should read the message and look for red curly brackets underneath variables. If you hover your mouse over them, further information about what is wrong can be provided.

OpenStudy (e.mccormick):

Or, from a logical standpoint, change the input line from in to size. This makes the variable name state what it is for.

OpenStudy (e.mccormick):

Also, it looks like you are using Eclipse. As Ivanskodje points out, that should make hover work for errors. Watch for the red underlines. Let me make an error in some exiting code and show you what that is like.

OpenStudy (e.mccormick):

You can also see on the left, near the line numbers, the error marker. There is another on the right, nect to the scroll bar, that gives a general idea of where in the file. So the ones on the right always show up where as the one on the left only shows when you can see the part of the file with the error.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!