I',m trying the basic of objects in java but I got this problem when I try
I have Dogs class
public class Dogs {
private String Name;
private int Age;
private String Color;
private String Owner;
public Dogs() {
this.Name = "Rex";
this.Age = 5;
this.Color = "black";
this.Owner = "John";
}
public Dogs(String name, int age, String color, String owner) {
this.Name = name;
this.Age = age;
this.Color = color;
this.Owner = owner;
}
//all the getters and setters
and Main class
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Dogs my_dog = new Dogs();
System.out.println("What is the dog's name? ");
my_dog.setName(input.next());
System.out.println("What is the dog's age? ");
my_dog.setAge(input.nextInt());
System.out.println("What is the dog's color? ");
my_dog.setColor(input.nextLine());
System.out.println("What is the owner's name? ");
my_dog.setOwner(input.nextLine());
}
}
when I run it, it prints the two questions fine but than it skip on the next...
this is the resault:
What is the dog's name?
pil
What is the dog's age?
7
What is the dog's color?
What is the owner's name?
how can I fix it?