search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
89 views
asked Sr Member 4.8k points 10 25 31

1 Answer

0 votes
It is legal to have these two methods in the same class.

public class MainClass {
  public int printNumber(int i) {
      return i*2;
  }

  public long printNumber(long i) {
      return i*3;
  }
  public static void main(String[] args) {

  }

}
printNumber(3) will invoke this method:
public int printNumber(int i)
To call the second, pass a long:
printNumber(3L);
answered Expert 11.4k points 14 22 28

Related questions

0 votes
1 answer 88 views
0 votes
1 answer 88 views
88 views
asked smith Geek 15.3k points 16 41 63
0 votes
1 answer 15 views
15 views
asked sara Guru 24.6k points 29 52 81
0 votes
1 answer 92 views
92 views
asked augustaina Sr Member 4.8k points 10 25 31
0 votes
1 answer 104 views
104 views
asked sunny Expert 11.4k points 14 22 28
...