Question: How can I make a method to print both integers and strings?
I tried

```
public static void print(String txt){
    System.out.println(txt);
}

```

This way I can only print Strings.

Sorry for my noobish question but I tried searching, but nothing (I'm propably using the wrong keywords)

Thanks for advance.

Answer: 
Overloading it.

```
public static void print (String txt) {
    System.out.println(txt);
}

public static void print (int txt) {
    System.out.println(txt);
}

```

*Or* converting all values to strings before passing it to the function using the Object [`toString`](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString%28%29) method.
```
class SamplePrint
{

  public static void main(String txt)
  {
    System.out.println(txt);
  }

  public static void main(int txt)
  {
    System.out.println(txt);
  }

  public static void main(String args[])
  {
    // This will automatically calls to print() which has string type arguments
    print("Hello Friend");

    // This will automatically calls to print() which has int type arguments
    print(100);
  }
}

```