Click here to Skip to main content
15,890,882 members
Home / Discussions / Java
   

Java

 
GeneralRe: Java Interface Componants Pin
kanishka_300027-Oct-10 2:30
kanishka_300027-Oct-10 2:30 
GeneralRe: Java Interface Componants Pin
Richard MacCutchan27-Oct-10 2:37
mveRichard MacCutchan27-Oct-10 2:37 
Questioncoding for implementing antivirus software [modified] Pin
kulbhushan125-Oct-10 1:16
kulbhushan125-Oct-10 1:16 
AnswerRe: coding for implementing antivirus software Pin
Cedric Moonen25-Oct-10 1:37
Cedric Moonen25-Oct-10 1:37 
QuestionPassing Parameters in Methods Pin
vidhyaej25-Oct-10 0:25
vidhyaej25-Oct-10 0:25 
AnswerRe: Passing Parameters in Methods Pin
Alok Sharma ji25-Oct-10 0:46
Alok Sharma ji25-Oct-10 0:46 
GeneralRe: Passing Parameters in Methods Pin
vidhyaej25-Oct-10 2:08
vidhyaej25-Oct-10 2:08 
GeneralRe: Passing Parameters in Methods Pin
Gerben Jongerius25-Oct-10 3:03
Gerben Jongerius25-Oct-10 3:03 
There are a few things which are going wrong.

1. int sum=obj.sum(int a,int b); is a big nono (you cannot call a function like this)
2. getvalue ask for two numbers but never actually stores it for use (unless you count the local int a and int b as storing it for further use.

You should store the value a and b on instance level, eg:
class Sum {
  protected int a;
  protected int b;

  public void getvalue() throws NumberFormatException, IOException
  {
   System.out.println("Enter two numbers :");
   BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

   a=Integer.parseInt(br.readLine());
   b=Integer.parseInt(br.readLine());
  }

  public int sum(int a,int b)
   {
          return(a+b);
   }

  static void main(String args[]) {
      Sum obj=new Sum();
      obj.getvalue();
      int sum=obj.sum(obj.a,obj.b);
      System.out.println("Sum :"+ sum);
  }
}

AnswerRe: Passing Parameters in Methods Pin
Richard MacCutchan25-Oct-10 6:16
mveRichard MacCutchan25-Oct-10 6:16 
QuestionHow to capture image via web cam and display in JAVA/JSP/Servlet Pin
Alok Sharma ji24-Oct-10 23:38
Alok Sharma ji24-Oct-10 23:38 
AnswerRe: How to capture image via web cam and display in JAVA/JSP/Servlet Pin
Gerben Jongerius25-Oct-10 2:56
Gerben Jongerius25-Oct-10 2:56 
GeneralRe: How to capture image via web cam and display in JAVA/JSP/Servlet Pin
Alok Sharma ji25-Oct-10 21:03
Alok Sharma ji25-Oct-10 21:03 
Generalabt java project Pin
cool_vishwas23-Oct-10 18:20
cool_vishwas23-Oct-10 18:20 
GeneralRe: abt java project Pin
Peter_in_278023-Oct-10 18:35
professionalPeter_in_278023-Oct-10 18:35 
GeneralRe: abt java project Pin
Richard MacCutchan23-Oct-10 21:52
mveRichard MacCutchan23-Oct-10 21:52 
GeneralRe: abt java project Pin
Cedric Moonen24-Oct-10 20:41
Cedric Moonen24-Oct-10 20:41 
GeneralRe: abt java project Pin
_Erik_25-Oct-10 4:58
_Erik_25-Oct-10 4:58 
Questionjava stacks Pin
Sylvane23-Oct-10 4:18
Sylvane23-Oct-10 4:18 
AnswerRe: java stacks Pin
Richard MacCutchan23-Oct-10 21:47
mveRichard MacCutchan23-Oct-10 21:47 
QuestionJTabel Cell Pin
trioum22-Oct-10 19:53
trioum22-Oct-10 19:53 
AnswerRe: JTabel Cell Pin
David Skelly24-Oct-10 22:16
David Skelly24-Oct-10 22:16 
QuestionNeed help with this code [modified] Pin
zooropean720-Oct-10 16:33
zooropean720-Oct-10 16:33 
AnswerRe: Need help with this code Pin
Bugclear20-Oct-10 21:32
Bugclear20-Oct-10 21:32 
GeneralRe: Need help with this code Pin
Richard MacCutchan20-Oct-10 22:10
mveRichard MacCutchan20-Oct-10 22:10 
GeneralRe: Need help with this code Pin
zooropean721-Oct-10 8:33
zooropean721-Oct-10 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.