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.
```
Using generics
----------------
package simlpe;

public class simple
{                        
   public static < E > void print( E input)
   {

         System.out.println(input);
    }

    public static void main( String args[] )
    {
        // Creates a  Integer, Double and Character
        Integer A = 1;
        Double d = 1.1;
        Character ch = 'H';

        print( A ); // pass an Integer
        print( d ); // pass a Double 
        print( ch ); // pass a Character 
    } 
}

```