Java Tutorial 15. Switch statements

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,912
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 23, 2008

The switch statement

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (Zantorc)

  • (First '=>' isn't an operator so I assume you mean '>='). You can use these operators but only in a rather contrived way. The word 'case' has to be followed by a constant known at compile time. Also it has to be assignable to the type of the expression which follows the word 'switch'. That expression in turn must be of type byte, Byte, short, Short, char, Character, int, Integer or an enum type. NOT boolean.

  • I had an example which illustrates this but after over an hour of trying I've discovered youtube blocks anything which doesn't look like plain text.

    Basically whatever you put after 'case' has got to be known at compile time. It could be a ternary expression involving conditional operators, which looks a bit odd, but it works. The important thing is the compiler can work out what it is (so you might as well have put that value in to begin with).

see all

All Comments (2)

Sign In or Sign Up now to post a comment!
  • check out my channel for java programming tutorials!!!

  • Hey. I was wondering if you could use the '>' or '=>' operators etc. in the cases?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more