Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with Brackets and Array Declaration
    text
    copied!<p>So I'm working on my application and I'm simply trying to declare a new array of strings. For some reason it wants an extra bracket to close the class at the end (even though the brackets are fine), and also after "private String[] addSentences = new String[3];" if asks for "{" instead of ";". In other words it wants to close something...I don't get it. Maybe you guys can help.</p> <pre><code>package org.chinesetones.teacher; import java.util.ArrayList; import android.app.Activity; import android.app.Dialog; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Gravity; import android.view.View; import android.widget.Toast; import android.view.View; import android.view.View.OnClickListener; import org.chinesetones.teacher.Sentence; public class Game extends Activity implements OnClickListener { private String[] addStrings = new String[3]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.game); // Setup button listeners... View nextButton = findViewById(R.id.next_button); nextButton.setOnClickListener(this); View repeatButton = findViewById(R.id.repeat_button); repeatButton.setOnClickListener(this); } public void onClick(View v){ switch(v.getId()) { case R.id.next_button: giveSentence(); break; case R.id.repeat_button: playSentence(); break; } } private ArrayList&lt;Sentence&gt; sentences; private String[] addSentences = new String[3]; addSentences[0] = "Hi"; addSentences[1] = "No"; addSentences[2] = "Yes"; } </code></pre> <p>giveSentence() and playSentence() have not been created yet. The errors are below.</p> <p>Description Resource Path Location Type Syntax error on token ";", { expected after this token Game.java /ChineseTones/src/org/chinesetones/teacher line 39 Java Problem</p> <p>Description Resource Path Location Type Syntax error, insert "}" to complete ClassBody Game.java /ChineseTones/src/org/chinesetones/teacher line 43 Java Problem</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload