Need help on Language families

link to the project:

Hi i have been having problem with the file. Specifically with step 8 of the project. I ran the code on the file and i get this output.

output: null is spoken by 0 people mainly in Central America.

The language follows the word order: verb-object-subject

Fun fact: null is an ergative language.

My source code:
public class Language{

// instance fields
protected String name;
protected int numSpeakers;
protected String regionsSpeaker;
protected String wordOrder;

public Language(String name, int numSpeakers, String regionsSpeaker, String wordOrder){ = name;
this.numSpeakers = numSpeakers;
this.regionsSpeaker = regionsSpeaker;
this.wordOrder = wordOrder;

public void getInfo(){
System.out.println(name + " is spoken by\n" +
numSpeakers + " people mainly in " + regionsSpeaker + “\n”
+ "The language follows the word order: " + wordOrder);

public static void main(String args){
Language greek = new Language(“Greek”, 200000, “Europe”,“subject-verb-object”);

// call 

// call mayan lang
Mayan kiche = new Mayan("Ki'che'",2330000);


public class Mayan extends Language{
int speakers;
String languageName;

	public Mayan(String languageName, int speakers) {
		super(languageName, speakers, "Central America", "verb-object-subject");

	public void getInfo() {
	System.out.println(languageName + " is spoken by " + speakers + " people mainly in " + regionsSpeaker + ".");
	System.out.println("The language follows the word order: " + wordOrder);
	System.out.println("Fun fact: " + languageName + " is an ergative language.");


I am clueless as to how to get around this problem. any help is appreaciated.
Edit: I have found the solution, after just typing things out randomly.
add : this.languageName; this.speakers = this.numSpeakers;
I still don’t understand how this works, but it works. But any explanation at all is appreaciated.

In which case, did you really “find” the solution? Or did you just stumble upon something which seemed to do what you want, and assume that it worked without questioning it further? :slight_smile:

You may need to re-visit, or spend some more time on, classes if this is confusing you.

Inside of your declaration for public Mayan, you’re invoking the super() function to call the constructor for the parent class. This initialises the class attributes defined in Language, so that: = languageName
Language.numSpeakers = speakers
Language.regionsSpeaker = "Central America"
Language.wordOrder = "verb-object-subject"

Nowhere do you actually initialise the class attributes for Mayan, so when you’re calling kiche.getInfo(), these attributes are null/zero because you’ve never done anything with them - but it does have the four attributes listed above through inheritance.

That’s why, when you do - for example - this.languageName =, what you’re actually doing is saying Mayan.languageName = The this keyword refers to the current object, that being an instance of Mayan.

Mayan has inherited the attribute name from the superclass Language, which you initialised, and that’s why you’re able to assign that value to Mayan.languageName as you have done.

You either need to change your Mayan constructor to initialise the class attributes languageName / speakers or just re-use the existing attributes inherited from Language. (I’m unsure which approach is appropriate, as I can’t see the project because I don’t have Pro!)

Does that make any sense? :slight_smile: