Java Input/Output

class name error

Page 1 of 1

3 Replies - 992 Views - Last Post: 18 November 2010 - 05:22 AM Rate Topic: -----

#1 tashlee   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 28-August 10

Java Input/Output

Posted 17 November 2010 - 08:58 PM

I am trying to learn input and my program works properly but I get an error for the class line. Can someone tell me how to correct this error? Error: class name is public, should be declared in the file named main.java.

Thanks


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mortgagecalculator1;

import java.util.Scanner;
public class main{
    public static void main (String[] args) {
        System.out.println("Enter the value your mortgage loan amount on the line below and press enter?");
        Scanner scan = new Scanner(System.in);
        String ml = scan.nextLine();
        System.out.println("Your loan is:" +ml);

    }
}


Is This A Good Question/Topic? 0
  • +

Replies To: Java Input/Output

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Java Input/Output

Posted 17 November 2010 - 09:09 PM

Moved to Java. Simple programming question
Was This Post Helpful? 0
  • +
  • -

#3 sh1n3   User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 164
  • Joined: 22-April 10

Re: Java Input/Output

Posted 18 November 2010 - 04:47 AM

I wonder if you are allowed to use "main" as the name of your class, isn't it a keyword?
Was This Post Helpful? 0
  • +
  • -

#4 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3550
  • View blog
  • Posts: 16,190
  • Joined: 20-September 08

Re: Java Input/Output

Posted 18 November 2010 - 05:22 AM

Use public class Main
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1