User Profile

Collapse

Profile Sidebar

Collapse
Bret Little
Bret Little
Last Activity: Aug 9 '10, 03:55 PM
Joined: Aug 2 '10
Location: Utah, USA
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Bret Little
    replied to Java command passing args, help?
    in Java
    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...
    See more | Go to post

    Leave a comment:


  • Bret Little
    replied to incorrect listing
    in Java
    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()
    See more | Go to post

    Leave a comment:


  • Bret Little
    replied to Java command passing args, help?
    in Java
    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");
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...