Jimmy,
The point of your for loop is to check each element of args to see if it is equal to "help". Args is an array of Strings that you pass into your program when you run it. It could have a length of 2,3, or 20. Because of this, you need to test if s.equals("help" ) rather than args[2].equals("help") . If you just test for args[2], then you are only checking for the 3rd element of the array, and in...
User Profile
Collapse
-
Hi there,
In order for a sufficient response to your question, I think that you need to provide more of an explanation of what is going on (ie. more code). For example, why do you think the setStatus method is not working? What is it doing? Also, what does the findByExample() method do? It would seem to me if the setStatus method is working properly, then your problem would be somewhere in findByExamle()Leave a comment:
-
Hi Jimmy,
Because a String is an object, not a primitive type, you need to use the equals() method instead of ==
In short, your code should be:
Code:public class Echo { public static void main (String[] args) { for (String s: args) { System.out.println(s); if (args[2].equals("help")) { System.out.println("help");
Leave a comment:
No activity results to display
Show More
Leave a comment: