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
82 views
asked 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 by sunny Expert (11,410 points)

Related questions

0 votes
1 answer 81 views
0 votes
1 answer 81 views
81 views asked by smith Geek (15,340 points)
0 votes
1 answer 13 views
13 views asked by sara Guru (24,570 points)
0 votes
1 answer 85 views
85 views asked by augustaina Sr Member (4,820 points)
0 votes
1 answer 96 views
96 views asked by sunny Expert (11,410 points)
...