I've been searching around for ages and haven't found anyone who has had the same problem as me. When I run my program in Eclipse, everything looks fine. As soon as I run it in windows CMD, all special non-ASCII characters in my ArrayList are replaced with a ?. There are two attributes in the Dog class that are strings, namely "name" and "race".
Here's the code that prints the list in my main program:
System.out.println("\r\nLista på hundar i hundregistret: " + viewDogList.toString() + "\r\n");
Here's information from my Dog class, attributes, and methods used:
private String name; //attribute for the dog's name
private String race; //attribute for the dog's race
public Dog(String name, String race, int age, double weight)
public String getName() { //hämta hundnamn
return name;
}
public void setName (String name) { //sätta hundnamn
this.name = name;
}
public String getRace() {
return race;
}
public void setRace (String race) { //sätta hundras
this.race = race;
}
This is how the Dog list is constructed and the Dog object added:
ArrayList<Dog> viewDogList= new ArrayList<Dog>();
Dog dogInstance = new Dog("", "", 0, 0.0);
viewDogList.add(dogInstance);
When I print out the list in Eclipse after I've added a Dog object it is displayed as:
[Bjäbbis Schäfer 12 år 12.0 kg svans=14.4]
However, if I compile and run the program in CMD the same line is displayed as:
[Bj?bbis Sch?fer 12 år 12.0 kg svans=14.4]
Is there any solution into getting this to work? I have read something about bytes, string, character conversions but I don't think it's what I'm looking for!
EDIT: I forgot to mention that all strings unrelated to the ArrayList are properly displayed in the windows CMD. So its strange that only the ArrayList contents are displayed incorrectly.
I have also overrun the .toString method in the Dog class like so:
public String toString() {
return name + " " + race + " " + getAge() + " år " + getWeight() + " kg " + "svans="+ getTailLength();
}
Any help appreciated! TIA