-
Java codin help
keep gettin 2 error messages
(1)The field greeting cannot be declared static; static fields can only be declared in static or top level types
this is what the code looks like
Code:
public class comment {
/**
* @author Craig
*
* This class demonstrates use of:<br>
* Line Comments<br>
* Block Comments<br>
* JavaDoc Comments.<br>
*/
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 for the purpose
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);
}
}
}
-
First off you need to change your main method to public static void main (String args[]). Now look into the scope of variables. Where are you getting this stuff from? Someone is teaching you all wrong go google and search for java begginers tutorial or something like that.
Similar Threads
-
Replies: 2
Last Post: 06-14-2006, 03:16 PM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By Mike Tsakiris in forum .NET
Replies: 11
Last Post: 10-04-2002, 05:32 PM
-
By Anonymous in forum Java
Replies: 0
Last Post: 01-31-2002, 11:08 PM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks