Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-11-2006, 11:32 AM   #1 (permalink)
benzspida
Registered User
 
Join Date: Jun 2006
Posts: 10
benzspida is on a distinguished road
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);
		}
	}
}

Last edited by redhead; 07-11-2006 at 12:32 PM. Reason: It hurts my eyes when [code][/code] tags are missing...
benzspida is offline   Reply With Quote
Old 07-11-2006, 12:10 PM   #2 (permalink)
SeyelentEco
Registered User
 
Join Date: Jul 2006
Posts: 14
SeyelentEco is on a distinguished road
Sorry, its been a few years since I programmed Java, but is it because you have a class being defined within another class? Try moving the code defining the CommentsExample class outside the comments class.
SeyelentEco is offline   Reply With Quote
Old 07-11-2006, 02:54 PM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
SeyelentEco is correct. Get rid of the surrounding "comment" class, and it should work.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Resources Belisarius Java 0 03-28-2005 02:03 PM
Java Developer Position in Kansas City justplaindoug Java 0 10-29-2004 11:52 AM
IBM urges Sun to make Java open source redhead Code Newbie News 0 03-01-2004 10:39 PM


All times are GMT -8. The time now is 09:21 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting