Results 1 to 7 of 7

Thread: [RESOLVED] System.out.print question

  1. #1

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Resolved [RESOLVED] System.out.print question

    Hi,

    I would like to know about this code specifically the bold ones.
    Code:
       for(int i = 1; i<=3; i++)
       {
             System.out.print((i>1 ? ", " : " ") + myrecords.getString(i));
       }
    myrecords is declared as ResultSet...
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: System.out.print question

    What do you want to know about it?
    Every time the print is called "i" is tested if >1 ',' will be printed before the ResultSet.getString(i) otherwise (i<=1) an empty string will be printed instead
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: System.out.print question

    Hi,

    Is this similar to vb's IIf() function? Based on your explanation, the ", " is the true statement? and " " or empty string is the false statement? Hmmm, Im just new to java database and am curious with this things, anyway I also started to like java...

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: System.out.print question

    It's exactly the same, yes.

    Keep on with java, you'll love it
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: System.out.print question

    Ok,

    Thanks for your help..I'll be posting more on java soon enough..



    Greg
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Re: System.out.print question

    Quote Originally Posted by ComputerJy
    It's exactly the same, yes.
    Not exactly, but close enough. With VB's IIf(), both the true part and the false part will be evaluated before getting passed into IIf(). So if you are trying to do a check for Nothing before accessing an object's properties, IIf will still throw an exception.

    In Java, the false part is only evaluated if the test indeed returns false.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,024

    Re: [RESOLVED] System.out.print question

    Hi,

    Thanks for the enlightenment...

    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

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