Why can't I do something like this?
Making a 'print' class for personal use

Why can't I do that, yet I can do this:
Show message
Join up (it's free!) whether you're just starting out or you're crazy advanced. Get tips from people who know what they're talking about, without being treated like the playground smelly kid. Because seriously, your school classes didn't teach you anything you wanted to know.

Posted 07 May 2012 - 03:28 PM (#1)

<Imp> [F3ar 40] [PWNbear 17] [magik 15] [dissident 10] [mark 7]
Kyek, on 07 February 2011 - 07:11 AM, said:
Posted 07 May 2012 - 04:17 PM (#3)
Posted 07 May 2012 - 05:29 PM (#5)
Qasim, on 07 May 2012 - 04:17 PM, said:
Posted 08 May 2012 - 08:54 AM (#6)
inmethods return different types, they have the same name and have the same parameter types, so the Java compiler does not know the difference between the two.
/**
* Test class used as an example for Quinn.
*/
public class Test {
Scanner scanner;
/**
* Constructor initializes the scanner to system input.
*/
public Test() {
this.scanner = new Scanner(System.in);
}
/**
* Reads the next integer from the scanner with a prompt.
* @param prompt the prompt to ask the user
*/
public int inputInt(String prompt) {
out(prompt);
return this.scanner.nextInt();
}
/**
* Reads the next string from the scanner with a prompt.
* @param prompt the prompt to ask the user
*/
public String inputString(String string) {
out(string);
return this.scanner.next();
}
/**
* Shortcut to the System.out.print.
*/
public void print(Object object) {
System.out.println(object.toString());
}
}
reputation += 1 if post.is_helpful else 0
Posted 08 May 2012 - 09:40 AM (#7)
ianonavy, on 08 May 2012 - 08:54 AM, said:
inmethods return different types, they have the same name and have the same parameter types, so the Java compiler does not know the difference between the two.
Posted 08 May 2012 - 11:05 AM (#8)
public Integer someFunc(int a, int B)
{
//do something
}
public String someFunc(int a, int B)
{
//do something
}
public static void main(String[] args)
{
Object myVar = someFunc(1, 2);
}
Posted 08 May 2012 - 02:30 PM (#9)
<Imp> [F3ar 40] [PWNbear 17] [magik 15] [dissident 10] [mark 7]
Kyek, on 07 February 2011 - 07:11 AM, said:
Posted 08 May 2012 - 03:34 PM (#10)
ThatRailsGuy, on 08 May 2012 - 09:40 AM, said:
reputation += 1 if post.is_helpful else 0
Posted 08 May 2012 - 03:44 PM (#11)
ianonavy, on 08 May 2012 - 03:34 PM, said: