The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Switch statement

Posted by kaushik on December 22, 2000 at 11:52 PM

Recently i have came accross a problem mentioned in JAVA2, THE COMPLETE REFERENCE,(CHAPTER JAVA.IO.*).The program reads a string(s) and stotred in a byte array buf through s.getbytes.Later the object of ByteArrayInputStream f is created while passing "buf" in command line argument.
here i am giving the problematic portion

......
......
boolean marked=false
int c;
while((c=f.read())!=-1)
switch(c)

case '&': ......
......
break;

case';': ......
.......
system.out.print((char)c);
.....
......


Now my question is how c(which is an integer) can be compared with case statement(which is charecter by assigning single quote)

However the program works fine and gives the correct output.

Can anyone help?

kaushik




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us