// Create a class called Dog containing two String: name and says. In main(), create two dogs objects
and assign it to spot's object.
class Dog {
String name;
String says;
}
public class DogSays {
public static void main(String[] args) {
Dog D1 = new Dog();
Dog D2 = new Dog();
D1.says = "Woof!";
D1.name = "Scruffy!";
D2.says = "Bark!";
D2.name = "Spot!";
System.out.println("Hi! My name is " + D1.name);
System.out.println(D1.says);
System.out.println("Rooooooooowr! I'm " + D2.name);
System.out.println(D2.says);
}
}
I’ve been checking this for an hour and I don’t have any idea what’s wrong. I get a class, enum, or interface error expected and also a unclosed character literal. I think it’ something with the quotes.
The problem “Unclosed character literal” is here:
Make it:
You can not have stray comments without leading
//or not enclosed in/*and*/pairs…