Results 1 to 8 of 8

Thread: object check

  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default object check

    I am writing a program for a local texting app. one of the things i need to do is check if files exist. and if they don't, then to take action. here is the code that checks what the method returns (either "true" or "false"
    Java Code:
    checkParams check = new checkParams();
    		System.out.println(check);
    		
    		if (check.equals("true")) {
    			System.out.println("There are some files that do not exist!");
    		}
    when i print out check, i get "true", but this does not print out...

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default Re: object check

    Have you overriden checkParams equals() method?

  3. #3
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: object check

    gr.... i thought since it would return a string, i could use that directly. but i guess it just sets the object = to that string.

    checkParams check = new checkParams();
    System.out.println(check.toString());
    if(check.toString().equals("true")) {
    System.out.println("hi");
    }

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default Re: object check

    :confused:

    If all the checkParams class does is hold a "true" or "false" String then why not just use boolean or Boolean?

  5. #5
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: object check

    not sure what you are saying. are you saing the checkParams class should return a boolean instead?

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default Re: object check

    No. You appear to be comparing a checkParams object to the String "true". I was just confused as to what purpose the checkParams class is because if you want to know if it is "true" then the first thing that comes to my mind is boolean. Without context it seems that your checkParams class is a pseudo boolean object. If so then why not just use a boolean and get rid of the checkParams class?

  7. #7
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: object check

    ok, so i guess i need to kinda re-think this. what if the checkParams checked if the files exist, and if there are any errors, it would return them in an array of strings?

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default Re: object check

    Check if what files exist? The Java API has a File class which has a method that performs a check. Perhaps you should be using that instead. But then again since I have no idea what your overall goal is, it could be the wrong thing to do.

Similar Threads

  1. Replies: 1
    Last Post: 02-02-2011, 06:11 PM
  2. Replies: 5
    Last Post: 11-14-2010, 04:28 PM
  3. Replies: 2
    Last Post: 06-22-2010, 04:29 AM
  4. Replies: 2
    Last Post: 01-29-2010, 02:01 AM
  5. Replies: 1
    Last Post: 03-04-2009, 06:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •