Results 1 to 5 of 5

Thread: Clear out an int

  1. #1

    Thread Starter
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    how do i completely erase any value from an integer vairable?

    this does not work:

    Code:
    theint = null;

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  2. #2
    Guest

    Lightbulb

    I didn't notice that working in c/c++ except when using NULL instead of null, but in Java, you might use an Integer object which wraps an int primitive; then you can set the Integer object to null.

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Yes VirtuallyVB is right. The literal value NULL is used to
    identify the fact that an Object is not assigned to a variable.... It can be used with any variable that is not
    of a primative data type.... and int is a primative data type.

  4. #4
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    I was wondering this too, I was trying to use it to ckeck a text field to see if the user did not enter any input when a button is pressed.
    Alcohol & calculus don't mix.
    Never drink & derive.

  5. #5
    Guest

    Thumbs up Wynd

    TextField
    public String getText()

    String
    public int length()

    Code:
    TextField aTextField;
    ...
    int theint = aTextField.getText().length();
    
    if(theint == 0){
     //Then the user did not enter any input when a button is pressed.
    }

Posting Permissions

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



Click Here to Expand Forum to Full Width