Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Junky

Thread: Strange java syntax

  1. #1
    weps is offline Member
    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0

    Default Strange java syntax

    i have been programming java since 2 months and its ze first time that i have came across this ---

    max = (i > j) ? i : j;
    min = (i < j) ? i : j;

    these are from a program THAT works but i don't undestand anything,google doesn't help at all and i have checked 1 e-book(1000 pages) ... nada

    If any1 could help it would be great ... just explain whats going on here

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

    Default Re: Strange java syntax

    This is known as the ternary operator and is basically an if statement in disguise.

    max = (i > j) ? i : j;

    If i is greater than j assign i to max else assign j to max.
    yellowledbet likes this.

  3. #3
    yellowledbet is offline Senior Member
    Join Date
    Feb 2011
    Location
    Georgia, USA
    Posts
    122
    Rep Power
    0

    Default Re: Strange java syntax

    Google 'java ternary operator'.

  4. #4
    weps is offline Member
    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0

    Default Re: Strange java syntax

    thanks guys ... i guess 1 idiot out of the way ... lol

Similar Threads

  1. What type of java syntax is this?
    By castiel in forum New To Java
    Replies: 2
    Last Post: 02-07-2011, 06:59 PM
  2. Java Syntax If statement
    By Blasz in forum New To Java
    Replies: 9
    Last Post: 09-01-2010, 12:21 PM
  3. Java syntax I don't understand - assignment
    By poet in forum New To Java
    Replies: 2
    Last Post: 09-19-2009, 06:47 AM
  4. Java JDBC/MySQL appropriate Syntax
    By thelinuxguy in forum Advanced Java
    Replies: 7
    Last Post: 02-10-2009, 07:57 PM
  5. Replies: 4
    Last Post: 06-25-2008, 08:09 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
  •