aspose file tools*
The moose likes Beginning Java and the fly likes Error in the Following Code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in the Following Code." Watch "Error in the Following Code." New topic
Author

Error in the Following Code.

Zeeshan Saleem
Greenhorn

Joined: Mar 01, 2005
Posts: 2
class zee
{
public static void main (String args[])
{
short a = 10, b = 20 , c;
c = a + b;
System.out.println (c+" ");
}
}

==========================================
Please Correct that Code. zeeshan_saleem@gawab.com
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Did you get a compiler error? If so, please post it so we can show you how to interpret the error message. This is a very important skill to learn early.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
yup, there will be a compiler error.
There's of course also the glaring style error in the class name, not to mention the lack of a package (neither of them actually illegal but both bad practice).


42
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130
Zeeshan,

As David has already pointed out, you should post the compiler error you are receiving. In addition to this, you also need to check out some Java coding conventions as suggested by Jeroen. Here are the recommended coding conventions from Sun's java website:

Code Conventions for the Java Programming Language

I don't agree 100% with ALL of the standards in this document, but most of it is applicable. I would start with Section 9 - Naming Conventions.

Now back to the problem with your code snippet - just a small hint that may assist in solving your issue - read up on Java numeric data types and how Java arithmetic works. Also check out the topic of casting.

Good luck!

Regards,
JD
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

This thread apparently continues here.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in the Following Code.