小编use*_*814的帖子

使用switch语句后变量不可用?

所以这是我的作业,对我而言,它似乎是一个可变范围的问题.我已经尝试定义一个全局,但也许我做错了,因为这似乎也不满足我的编译器.我目前正在使用SublimeText2进行代码编写,但似乎没什么帮助.我应该使用Eclipse或Aptana Studio等IDE吗?

// EmployeeBonus2.java - This program calculates an employee's yearly bonus.

import javax.swing.*;

public class EmployeeBonus2
{
    public class Globals {
    public double employeeBonus;
}
  public static void main(String args[])
  {
    // Declare and initialize variables.
    String employeeName;
    String salaryString;
    double employeeSalary;
    String ratingString;
    int employeeRating;
    double employeeBonus;
    final double BONUS_1 = .15;
    final double BONUS_2 = .10;
    final double BONUS_3 = .06;
    final double NO_BONUS = 0.00;
    final int RATING_1 = 1;
    final int RATING_2 = 2;
    final …
Run Code Online (Sandbox Code Playgroud)

java variables scope case switch-statement

0
推荐指数
1
解决办法
2276
查看次数

标签 统计

case ×1

java ×1

scope ×1

switch-statement ×1

variables ×1