I proceeded to study Java according to the book "Practical Java Gamenics Easy Master Kindle Edition", but it was stopped again by haste. ..
D:\Study>javac -encoding UTF-8 edu\rpg\personal\GenderClass.java edu \ rpg \ personal \ GenderClass.java: 3: Error: Enum cannot be instantiated public static GenderClass MALE = new Gender2 ("male"); ^ edu \ rpg \ personal \ GenderClass.java: 4: Error: Enum cannot be instantiated public static GenderClass FEMALE = new Gender2 ("female"); ^ 2 errors
I wrote it briefly using enum in WeaponType.java to list the types of weapons.
package edu.rpg.weapon;
public enum WeaponType {
SWORD,
HUNMER,
KATANA
}
In Exercises12, I'm trying to create a Gender class to describe the gender of a String using an enumeration type, but in the middle of the story it becomes Gendere2.java, and it is explained in GenderClass.java. GenderClass.java
package edu.rpg.personal;
public class GenderClass {
public static GenderClass MALE = new Gender2("Man");
public static GenderClass FEMALE = new Gender2("woman");
private String name;
private GenderClass(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
Going around, it seems that errors are commonplace. The story goes on without touching this. In the story, I added a variable to count the population and explained the timing of instantiation, but it was a problem before that.
What did you do?
Is it okay because I learned a little about how to write markdown?
Recommended Posts