Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New to java, problems.

    Hi,
    Im having a problem running .java programs in cmd prompt, its compiles ok but when i go to run it, example -->(java prac8prog1)
    it brings up the following error:
    "Exception in thread "main" java.lang.NoSuchMethodError: main"
    Im using a JAR file ( import B102.*; ) at the top of my programs, that I was told to use, could this be whats the causing the error?

    Also I need some help with a different program I have to do, I need to know how to set out a character array for the 26 letters in the alphabet. Im pretty sure what i started doing below is wrong and i need some advice

    (This is the question im answering)
    "Write a Java program which reads in a string from the keyboard and then reports how many times each letter of the alphabet occurs within that string (ignoring case). It should also report how many non-letters are included in the string."


    Code:
    class Assignment2prog1
    {
        public static void UserInput()
        {
            public String Data = new String()
            Screen.out.println("Please enter a series of character values from the keyboard: ");
            String.toLowerCase()
            Data=keybd.in.readchar();
            return Data;
        }
    
        public static void Calculate()
        {
        	private char calcArray[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        	private int index;
            //??
            for(index=0; i<?; index++)
        }
    
        public static void Display()
        {
    
        }
    /*******************************************************************************
    ********************************************************************************
    			  MAIN PROGRAM STARTS HERE
    ********************************************************************************
    *******************************************************************************/
    
        public static void Main(string args[])
        {
        	int Input=0
        	
        	Input = UserInput();
        }
    }
    
    /*******************************************************************************
    ********************************************************************************
    			  MAIN PROGRAM ENDS HERE
    ********************************************************************************
    *******************************************************************************/
    Any help would be greatly appreciated.
    Thanks.

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The name of the entry point function should be main() and not Main().

    shmoove

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    and it should be String args[] not string args[]. Watch your capitalization as Java is a case sensitive language.

    As far as your second program since this does appear to be a homework assignment we cannot write or give any code to you. You must write it yourself but we can answer specific questions. I would suggest consulting your instructor first on what you've done so far. Honestly there is so much wrong with it right now I don't even know where to begin. I'll point out just a few areas you should probably read through your textbook or class notes on.

    -Review how loops work, specifically "for" loops.
    -Review the difference between declaring a method or data member public or private
    -Review proper Java naming conventions specifically in the area of capitalization. When to capitalize a variable name or method name
    -Review what instantiable classes are and how to implement them.
    -Review how to read in input from the user and how to output to the screen. Hint...it's System.out.println no Screen.out.println. For the input you will need to use some kind of input reading class or combination of classes. There are several to choose from.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •