Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-22-2013, 03:36 PM   PM User | #1
hrenfrow
New to the CF scene

 
Join Date: Jan 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
hrenfrow is an unknown quantity at this point
Question Simple JAVA code help

I am new to this, and have wrote the code, but keep getting the same error and completely clueless on what to do next. Any help would be greatly appreciated.


import java.util.*;
public class A1RE5161843 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter length of rectangle :");
double length = input.nextDouble();

System.out.print("Enter width of rectangle :");
double width = input.nextDouble();

System.out.println("Area: "+(length * width));
System.out.println("Perimeter: "+((2*length)+(2*width)));
}

}




Main.java:12: class A1RE5161843 is public, should be declared in a file named A1RE5161843.java
public class A1RE5161843 {
^
1 error
hrenfrow is offline   Reply With Quote
Old 01-22-2013, 05:23 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
The code compiles and runs fine. It looks like you don't have the correct file name in use, or that you're not running the javac properly if manually doing it from the command line.
Did you use an IDE for this, or did you just create a text file? Check the directory for this, and see what the extension is (it has to be .java).
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:56 PM.


Advertisement
Log in to turn off these ads.