View Full Version : Programming beginner stuck on simple

12-14-2011, 03:35 AM
I have a simple project that is getting me stuck. The current submission is included. The question is:
Write a class named Acc2 containing:
An instance variable named sum of type integer, initialized to 0.
A method named getSum that returns the value of sum .

This is my current sumbission:
public class Acc2
private int sum = 0;
public int getSum (){method sum;}

The system says that the only thing wrong with it is the bold word method. I have tryed many things in place of it however I am unable to move on.

12-14-2011, 03:46 AM
Same problem as your last post. Wrong forum.

Are you sure you took the right class?

Old Pedant
12-14-2011, 03:51 AM
A method named getSum that returns the value of sum .

And that didn't give you any clues?

Are you sure you have read the first two chapters of your course material?

And, yes, that answer would be true in JavaScript as much as it is in Java, but then it would be true in PHP, C, C++, C# and a raft of other languages. So aside from syntax similarities, it is still the case that Java and JavaScript are most similar in that their names start with the same 4 letters.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum