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 Overload based on the order of the arguments?

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

1 Answer

0 votes
public class MainClass {
  static void print(String s, int i) {
    System.out.println("String: " + s + ", int: " + i);
  }

  static void print(int i, String s) {
    System.out.println("int: " + i + ", String: " + s);
  }

  public static void main(String[] args) {
    print("String first", 11);
    print(99, "Int first");
  }
}
output
String: String first, int: 11
int: 99, String: Int first
answered May 10, 2014 by augustaina Sr Member (4,820 points)

Related questions

0 votes
1 answer 76 views
0 votes
1 answer 24 views
24 views asked Jan 9, 2014 by smith Geek (15,340 points)
0 votes
1 answer 77 views
77 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 48 views
0 votes
1 answer 10 views
...