如何在其他方法中调用变量

我想知道如何在另一个方法调用“ jButton 4 ActionPerformed”中访问局部变量“ AverageBodylengths”

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         


    float num3 = Integer.parseInt(jTextField5.getText());
    float num4 = Integer.parseInt(jTextField6.getText());
    float num5 = Integer.parseInt(jTextField7.getText());
    float num6 = Integer.parseInt(jTextField8.getText());
    float num7 = Integer.parseInt(jTextField9.getText());
    float num8 = Integer.parseInt(jTextField10.getText());
    float num9 = Integer.parseInt(jTextField11.getText());
    float num10 = Integer.parseInt(jTextField12.getText());
    float num11 = Integer.parseInt(jTextField13.getText());
    float num12 = Integer.parseInt(jTextField14.getText());

    float AverageBodylengths = (((num3) + (num4) + (num5) + (num6) + (num7) + (num8) + (num9) + (num10) + (num11) + (num12)) / 10);
    jLabel25.setText("" + AverageBodylengths + "mm");


}                                        

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {  

}
评论