Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJeff Christie
1,081 PointsError:(9, 8) error: class funfactsactivity is public, should be declared in a file named funfactsactivity.java
it says Error:(9, 8) error: class funfactsactivity is public, should be declared in a file named funfactsactivity.java under the FunFactsActivity.java Tab.. please help !
Jeff Christie
1,081 Pointspackage GoldenFacilities.funfacts;
import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem;
public class FunFactsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_facts);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.fun_facts, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
jon1234
5,022 PointsThe actual .java file must start with a capital letter, and the class name must exactly match the file name.
Jeff Christie
1,081 Pointshow do i change the java
Jeff Christie
1,081 PointsMy package name is now in capitals.. this is so confusing
1 Answer
Jon Kussmann
Courses Plus Student 7,254 PointsIn case this has not been resolved yet.
Your package name "GoldenFacilities.funfacts' should be in all lower case like so: "goldenfacilities.funfacts"
Your FunFactsActivity in the file and the file name (FunFactsActivity.java) should be the same, with the same casing and the first letter being upper case.
To change, I would right click what you want to change and use "refactor -> rename"
jon1234
5,022 Pointsjon1234
5,022 PointsWhere are you getting this error? Can you post your code from FunFactsActivity.java for us.