Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Error in the Following Code.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread apparently continues here.
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic