File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in the Following Code.

 
Zeeshan Saleem
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
John Dell'Oso
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This thread apparently continues here.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic