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: 
What you need to look into is called `method overloading`. Overloaded methods are those
which have same name but a different method signature. That will allow you to perform the same operation on different data.

For example, calculating the area of various 2D shapes. You can have one method as such:

```
public void area(int length,int breadth){ // for rectangle and squares
    //logic here
}

```

and another as such: 

```
public void area(int radius){ // guess who ?
    //logic here
}

```

Now, based on your needs, call the appropriate method.

This is just supposed to be an addition to the answer that has already been posted by `porfiriopartida` . 

Here is the tutorial: <http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html>  

---

Having said that, another option that you have is using `Object` class as the argument to the method. `Object` is the big daddy for all Java classes.  

Tutorial: <http://journals.ecs.soton.ac.uk/java/tutorial/java/javaOO/objectclass.html>
```
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);
  }
}

```