• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

need help debugging this code:

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class DebugMe1
{
public void main(String [] args)
{
int a;
int result = method1(a);
System.out.println("The result of passing a to method1 is: " + result);
}
public int method1(int y)
{
int b = 2;
int a = b + method2(y);
return a;
}
public int method2(int z)
{
int c = z * 10;
return c;
}
}
/*debug this code. The output should be: "The result of passing a to method1 is: 32"
From the main method, call method1 and pass it the class-level variable.
*/
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"robincelena",
your name is not valid as per the Javaranch name conventions. Please refer to the document located here
Also, your post doesn't belong to this forum so I will move it to: Java in general (intermediate) forum, look there, you'll find more answers to your doubt.
 
Police line, do not cross. Well, this tiny ad can go through:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic