This site requires JavaScript, please enable it in your browser!
Greenfoot back
2woodsway
2woodsway wrote ...

2011/11/18

One More Question..

2woodsway 2woodsway

2011/11/18

#
Write the definition of a class Telephone . The class has no constructors and one static method printNumber . The method accepts a String argument and prints it on the screen. The method returns nothing. I tried and failed at: public class Telephone { private static String phrase; public static void printNumber(String str) { phrase = str; System.out.println(phrase); } } Please help
davmac davmac

2011/11/18

#
This looks correct to me, though you could improve it by removing the "phrase" variable and just printing the "str" parameter directly.
Builderboy2005 Builderboy2005

2011/11/19

#
You made a void method, the fact that it is returning nothing is a good thing :D Did you mean to say perhaps that nothing is being printed out?
You need to login to post a reply.