我需要使用taxTables方法生成一个BogOff类,该方法初始化一个收入增加的整数数组,在上表中显示的每个收入范围中至少有一个,并使用TaxChart对象生成一个细条形图和相应的表格。
基本上,我已经完成了所有这些,并且它正在工作,但是对于我的生活,我无法将其移动到名为taxTable的方法中,我知道这看起来很荒谬,考虑到我已经写过的内容。
public class BogOff {
public static void main (String[] args) {
int[] Values = { 25, 50, 100, 125, 150, 175, 200, 225, 250, 275, 300,
325, 350, 375, 400, 425, 450, 500, 550 };
/*initialized my array of integers to used as the values of income
I will input*/
TaxChart graph = new TaxChart(Values); //calling my graph
graph.Initialize();
graph.Draw();
graph.PrintTable();
//my graph uses the 2 methods, Initialize and Draw from TaxChart to
//render the graph PrintTable is used to output my income, tax and
//income remaining
}
}
答案 0 :(得分:1)
public class BogOff {
public static void main (String[] args) {
initAndDrawGraph();
}
public static void initAndDrawGraph() {
int[] Values = { 25, 50, 100, 125, 150, 175, 200, 225, 250, 275, 300,
325, 350, 375, 400, 425, 450, 500, 550 };
/*initialized my array of integers to used as the values of income
I will input*/
TaxChart graph = new TaxChart(Values); //calling my graph
graph.Initialize();
graph.Draw();
graph.PrintTable();
//my graph uses the 2 methods, Initialize and Draw from TaxChart to
//render the graph PrintTable is used to output my income, tax and
//income remaining
}
}
由于main()
是静态的,因此从main调用的另一个方法要么必须是静态的,要么它可以是非静态方法,但是从BogOff
的实例调用,而不仅仅是来自main在BogOff
。