A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • one year ago

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

  • This Question is Closed
  1. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    1 Attachment
  2. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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; } } }}

  3. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  4. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    here the error message which i get

    1 Attachment
  5. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  6. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

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

  7. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  8. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  9. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.