Greatings there from the absolutely beginning of the coding way, I'm talking, less than a week (than 4 days, if to be correct).
So, here's my problem. I made a class User
and then gave it some variables (sorry if the way I'm writing is very casual and not programming-like).
public class User
{
String name;
short age;
int height;
Then I created some constructors. That's one of them:
public User(String name,short age,int height) {
this.name=name;
this.age=age;
this.height=height;
System.out.println(name);
System.out.println("Age: "+age);
System.out.println("Height: "+height);
System.out.println();
}
Afterwards, in the main
method I made a subject of the class User
with indicated aomounts of variables:
public static void main(String[] args) {
User user1=new User("Dan",20,190);
}
But when I run the programm, I get an error saying that there arent any constructor of (String,int,int) type. Meanwhile, if write (short)
,that is, specify the datatype, programm works. Why do Java see the the number matching the type of amount which short
requires as int
?