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

3,749 questions

4,049 answers

114 comments

10,705 users

How to Pass long parameters to overload method ?

0 votes
77 views
asked May 10, 2014 by augustaina Sr Member (4,820 points)

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 May 10, 2014 by sunny Expert (11,410 points)

Related questions

0 votes
1 answer 76 views
0 votes
1 answer 75 views
75 views asked May 10, 2014 by smith Geek (15,340 points)
0 votes
1 answer 12 views
12 views asked Apr 25, 2014 by sara Guru (24,570 points)
0 votes
1 answer 80 views
80 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 89 views
89 views asked May 10, 2014 by sunny Expert (11,410 points)
...