/    Sign up×
Community /Pin to ProfileBookmark

Java Error can any one help

I keep getting this java error (inner class cannot have static declarations ) dont know why I just started learning Java dont know what im doing wrong. Thanks

[code]
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.event.*;

public class comments extends Applet
{
/**
* @author Craig
*
* This class demonstrates use of:
* Line Comments
* Block Comments
* JavaDoc Comments.
*/
public class CommentsExample {

/**
* Program comments are nonexecuting,
* statements you add to a program
* documentation for the purpose
* of documentation.
*/
protected static String greeting = “Hi”;

//Program comments are nonexecuting,
//statements you add to a program
private static String name = “Guys”; //documentation

public CommentsExample() {
//of documentation.()
super();
}

/**
* This is the entry point of the application.
* main() is executed first by the JVM.
*/
public void main(String[] args) {
/*
* Program comments are nonexecuting,
* statements you add to a program
* documentation for the purpose
* of documentation.
*/
System.out.println(greeting + ” ” + name);
}
}
}

[/code]

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@CytaelAug 20.2006 — The error means exactly what it says: you can't have something declared "static" inside a nested class. You need to move or change the lines that say protected static String greeting = "Hi";
private static String name = "Guys";
×

Success!

Help @benzspida spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...