Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

output clarification

 
m prabhu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


will it compile and run without exception.please explain the result.
 
Milan Sutaria
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about running it?
answer is ... yes it will run without any error. '%s' invokes the toString() method on the object & so the output will be 123
[ July 22, 2008: Message edited by: Milan Sutaria ]
 
m prabhu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


when compiled:giving the following error.

symbol : method format(java.lang.String,java.lang.Long)
location: class java.io.PrintStream
System.out.format("%s", new Long("123"));
1 error

Please explain
 
Denis Bogdanov
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Java version do you have? The class PrintStream has the method format() in java 5.
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the same version of java as the one of the exam for which you are preparing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic