a very basic doubt in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • katrina
    New Member
    • Sep 2007
    • 1

    #1

    a very basic doubt in java

    Can i put a condition saying that "if a variable carries a srting content" like this way(im a very beginner to java )

    if(couple!=null )
    {
    do this.....
    }

    (couple is my variable)
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by katrina
    Can i put a condition saying that "if a variable carries a srting content" like this way(im a very beginner to java )

    if(couple!=null )
    {
    do this.....
    }

    (couple is my variable)
    Sure you can; if 'couple' is a non-primitive variable you can surely do that; in fact
    it's quite normal idiom.

    kind regards,

    Jos

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by katrina
      Can i put a condition saying that "if a variable carries a srting content" like this way(im a very beginner to java )

      if(couple!=null )
      {
      do this.....
      }

      (couple is my variable)
      Do not post questions in the articles section.
      Why don't you try it on the compiler and see what happens? The best way to learn these things is to read the appropriate tutorial and to try as much code on the compiler as possible.

      Comment

      Working...