Java codin help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Java codin help

  1. #1
    Join Date
    Jun 2006
    Posts
    6

    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);
    }
    }
    }

  2. #2
    Join Date
    Mar 2006
    Posts
    35
    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

  1. Replies: 2
    Last Post: 06-14-2006, 04:16 PM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 07:46 AM
  3. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 06:32 PM
  4. Replies: 0
    Last Post: 02-01-2002, 12:08 AM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 05: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center