Click here to Skip to main content
16,015,296 members
Home / Discussions / Java
   

Java

 
GeneralRe: Java Pin
Babayomi27-Apr-20 11:30
Babayomi27-Apr-20 11:30 
RantRe: Java Pin
ZurdoDev27-Apr-20 1:23
professionalZurdoDev27-Apr-20 1:23 
QuestionAndroid Studio submission Pin
Gammill18-Apr-20 10:34
Gammill18-Apr-20 10:34 
AnswerRe: Android Studio submission Pin
Gammill18-Apr-20 13:52
Gammill18-Apr-20 13:52 
QuestionIntroduction to object oriented programming Pin
Member 1479832810-Apr-20 6:59
Member 1479832810-Apr-20 6:59 
AnswerRe: Introduction to object oriented programming Pin
Richard MacCutchan10-Apr-20 21:17
mveRichard MacCutchan10-Apr-20 21:17 
Questioncannot resolve Pin
MallardsReach30-Mar-20 3:32
MallardsReach30-Mar-20 3:32 
AnswerRe: cannot resolve Pin
Richard MacCutchan30-Mar-20 3:50
mveRichard MacCutchan30-Mar-20 3:50 
You are creating local variables in one method, and then trying to access them from other methods. You need to understand the scope rules, i.e whether variables are local or not. So txtNumOne and txtNumTwo should be class level variables. Alternatively they could be passed as parameters to the showAnswer method.

You have a potential mistake in the following code:
Java
     String strAnswer; // this is a class level variable, i.e. visible to every method in the class

   void showAnswer(int dPlaces){
       Double numAnswer;
       // this has the same name as the class level variable,
       // but is only visible inside this method, so a possible conflict
       String strAnswer;
       // don't write compound statements like this, they are much harder to diagnose when things go wrong
       numAnswer = (Double.parseDouble(txtNumOne.getText()))* (Double.parseDouble(txtNumTwo.getText()));
       strAnswer = String.format("%,." + dPlaces + "f", numAnswer);
       lblDPAnswer.setText(strAnswer);

}

GeneralRe: cannot resolve Pin
MallardsReach30-Mar-20 6:29
MallardsReach30-Mar-20 6:29 
GeneralRe: cannot resolve Pin
Richard MacCutchan30-Mar-20 6:45
mveRichard MacCutchan30-Mar-20 6:45 
GeneralRe: cannot resolve Pin
MallardsReach30-Mar-20 10:32
MallardsReach30-Mar-20 10:32 
GeneralRe: cannot resolve Pin
Richard MacCutchan30-Mar-20 21:34
mveRichard MacCutchan30-Mar-20 21:34 
GeneralRe: cannot resolve Pin
Richard MacCutchan30-Mar-20 22:52
mveRichard MacCutchan30-Mar-20 22:52 
GeneralRe: cannot resolve Pin
MallardsReach30-Mar-20 23:22
MallardsReach30-Mar-20 23:22 
QuestionRadio Button Selected Pin
MallardsReach25-Mar-20 9:50
MallardsReach25-Mar-20 9:50 
QuestionRe: Radio Button Selected Pin
ZurdoDev25-Mar-20 10:10
professionalZurdoDev25-Mar-20 10:10 
AnswerRe: Radio Button Selected Pin
MallardsReach25-Mar-20 10:33
MallardsReach25-Mar-20 10:33 
QuestionRe: Radio Button Selected Pin
ZurdoDev25-Mar-20 10:39
professionalZurdoDev25-Mar-20 10:39 
AnswerRe: Radio Button Selected Pin
MallardsReach25-Mar-20 11:11
MallardsReach25-Mar-20 11:11 
QuestionRe: Radio Button Selected Pin
ZurdoDev25-Mar-20 12:19
professionalZurdoDev25-Mar-20 12:19 
AnswerRe: Radio Button Selected Pin
Richard MacCutchan26-Mar-20 0:16
mveRichard MacCutchan26-Mar-20 0:16 
GeneralRe: Radio Button Selected Pin
MallardsReach26-Mar-20 0:28
MallardsReach26-Mar-20 0:28 
GeneralRe: Radio Button Selected Pin
Richard MacCutchan26-Mar-20 0:36
mveRichard MacCutchan26-Mar-20 0:36 
GeneralRe: Radio Button Selected Pin
MallardsReach26-Mar-20 2:55
MallardsReach26-Mar-20 2:55 
GeneralRe: Radio Button Selected Pin
MallardsReach26-Mar-20 4:15
MallardsReach26-Mar-20 4:15 

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.