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: 
In addition to different signatures, you can also just use a generic parameter, such as an Object, and let Java do some [autoboxing](http://docs.oracle.com/javase/tutorial/java/data/autoboxing.html) for you:

```
class Untitled {

    public static void main(String[] args) 
    {
        U.log("test");
        U.log(45);
    }

    // U(tility)
    public static class U
    {
        public static void log( Object o )
        {
            System.out.println( o.toString() );            
        }
    }
}

```

I use one of those that takes an arbitrary number of parameters in every Java based project I work on.
```
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 
    } 
}

```