[英]Why can't I see the changes in my project but I see them in the fxml file?
[英]Why can't I see my project running in netbeans?
即使它以前工作過,我也無法讓我的項目正確運行。
import org.apache.commons.lang3.StringUtils;
import java.util.Scanner;
public class Main {
static void bar_graph(int un, int deux, int trois, int quatre, int cinque) { //creates method bar_graph to take 5 integers and, for each integer, return that many asterisk
int[] array = {un, deux, trois, quatre, cinque}; //creates array to hold the integers from bar_graph
String graph = "*"; //creates string equal to *
int counter = 0; //creates integer counter
while(counter < 5){ //beginning of while loop which goes through the five integers in bar_graph and prints out, for each integer, that many asterisk
String repeated = StringUtils.repeat(graph, array[counter]); //repeats the string graph as many times as the integer at array[counter] and equals it to a string called repeated
System.out.println(repeated); //string repeated is printed
counter++; //the counter increases by one
}
}
public static void main(String[] args) {
System.out.println("Emma Wilson - Programming Project 3 Exercise 4.16");
Scanner graph = new Scanner(System.in);
System.out.println("Please enter five integers between 1 and 30: "); //asks user to input five integers between 1 and 30
int first = graph.nextInt(); //creates int first and equals it to first integer the user enters here
while (first > 30 || first < 1){ //checks that the integer the user entered is between 1 and 30 and asks the user to enter an integer between 1 and 30 over and over
System.out.println("That is not an integer between 1 and 30. Please enter an integer between 1 and 30: ");
first = graph.nextInt();
}
int second = graph.nextInt(); //creates int second and equals it to next integer the user enters here
while (second > 30 || second < 1){ //checks that the integer the user entered is between 1 and 30 and asks the user to enter an integer between 1 and 30 over and over
System.out.println("That is not an integer between 1 and 30. Please enter an integer between 1 and 30: ");
second = graph.nextInt();
}
int third = graph.nextInt(); //creates int third and equals it to next integer the user enters here
while (third > 30 || third < 1){ //checks that the integer the user entered is between 1 and 30 and asks the user to enter an integer between 1 and 30 over and over
System.out.println("That is not an integer between 1 and 30. Please enter an integer between 1 and 30: ");
third = graph.nextInt();
}
int fourth = graph.nextInt(); //creates int fourth and equals it to next integer the user enters here
while (fourth > 30 || fourth < 1){ //checks that the integer the user entered is between 1 and 30 and asks the user to enter an integer between 1 and 30 over and over
System.out.println("That is not an integer between 1 and 30. Please enter an integer between 1 and 30: ");
fourth = graph.nextInt();
}
int fifth = graph.nextInt(); //creates int fifth and equals it to next integer the user enters here
while (fifth > 30 || fifth < 1){
System.out.println("That is not an integer between 1 and 30. Please enter an integer between 1 and 30: ");
fifth = graph.nextInt();
}
bar_graph(first, second, third, fourth, fifth); //calls method bar_graph
}
}
代碼截圖1:
代碼截圖2:
代碼運行截圖3:
當我運行它時,netbeans 不顯示我輸入的整數或任何輸出。
Netbeans 運行我正確編譯的另一個程序,但不是這個程序。
您嘗試運行一個文件,但運行的是最后一個文件而不是當前文件。
當使用main
方法打開多個項目或有多個文件並在 Netbeans 中按“運行”(或按 F6 運行)時,會發生這種情況,它會運行您運行的最后一個文件。
將其視為“運行我上次運行的程序”之類的鍵。
如果要運行另一個文件,只需使用main
方法打開文件,右鍵單擊代碼中的每個位置並按“運行文件”(或只需按快捷鍵 shift + F6)。
通過這種方式,您將告訴 Netbeans 不要運行我的最后一個代碼,而是運行這個代碼。
從現在開始,使用 IDE 頂部的“運行”鍵,運行此文件。 除非您對其他文件執行相同操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.