运行为^ R(CTRL R),但在Mac上不起作用。
反正我可以重新编写使用OPTION R之类的快捷方式吗?
答案 0 :(得分:0)
默认情况下,在Windows / Linux中public class Presidents
{
public int presidentNumber;
public String presidentName;
public int startingYear;
public int endingYear;
Presidents [] president;
public Presidents(int PresidentNumber, String NameOfPresident, int StartingYear, int EndingYear)
{
this.presidentNumber = PresidentNumber;
this.presidentName = NameOfPresident;
this.startingYear = StartingYear;
this.endingYear = EndingYear;
}
public Presidents() {
}
public Presidents [] PresidentList ()
{
president= new Presidents [45];
president [0] = new Presidents(1, "George Washington", 1789, 1797);
president [1] = new Presidents(2, "John Adams", 1797, 1801);
president [2] = new Presidents(3, "Thomas Jefferson", 1801, 1809);
president [3] = new Presidents(4, "James Madison", 1809, 1817);
president [4] = new Presidents(5, "James Monroe", 1817, 1825);
president [5] = new Presidents(6, "John Quincy Adams", 1825, 1829);
president [6] = new Presidents(7, "Andrew Jackson", 1829, 1837);
president [7] = new Presidents(8, "Martin Van Buren", 1837, 1841);
president [8] = new Presidents(9, "William Henry Harrison", 1841, 1841);
president [9] = new Presidents(10, "John Tyler", 1841, 1845);
president [10] = new Presidents(11, "James K. Polk", 1845, 1849);
president [11] = new Presidents(12, "Zachary Taylor", 1849, 1850);
president [12] = new Presidents(13, "Millard Fillmore", 1850, 1853);
president [13] = new Presidents(14, "Franklin Pierce", 1853, 1857);
president [14] = new Presidents(15, "James Buchanan", 1857, 1861);
president [15] = new Presidents(16, "Abraham Lincoln", 1861, 1865);
president [16] = new Presidents(17, "Andrew Johnson", 1865, 1869);
president [17] = new Presidents(18, "Ulysses S. Grant", 1869, 1877);
president [18] =new Presidents(19, "Rutherford B. Hayes", 1877, 1881);
president [19] =new Presidents(20, "James A. Garfield", 1881, 1881);
president [20] =new Presidents(21, "Chester A. Arthur", 1881, 1885);
president [21] =new Presidents(22, "Grover Cleveland", 1885, 1889);
president [22] =new Presidents(23, "Benjamin Harrison", 1889, 1893);
president [23] =new Presidents(24, "Grover Cleveland", 1893, 1897);
president [24] =new Presidents(25, "William McKinley", 1897, 1901);
president [25] =new Presidents(26, "Theodore Roosevelt", 1901, 1909);
president [26] =new Presidents(27, "William Howard Taft", 1909, 1913);
president [27] =new Presidents(28, "Woodrow Wilson", 1913, 1921);
president [28] =new Presidents(29, "Warren G. Harding", 1921, 1923);
president [29] =new Presidents(30, "Calvin Coolidge", 1923, 1929);
president [30] =new Presidents(31, "Herbert Hoover", 1929, 1933);
president [31] =new Presidents(32, "Franklin D. Roosevelt", 1933, 1945);
president [32] =new Presidents(33, "Harry S. Truman", 1945, 1953);
president [33] =new Presidents(34, "Dwight D. Eisenhower", 1953, 1961);
president [34] =new Presidents(35, "John F. Kennedy", 1961, 1963);
president [35] =new Presidents(36, "Lyndon B. Johnson", 1963, 1969);
president [36] =new Presidents(37, "Richard Nixon", 1969, 1974);
president [37] =new Presidents(38, "Gerald Ford", 1974, 1977);
president [38] =new Presidents(39, "Jimmy Carter", 1977, 1981);
president [39] =new Presidents(40, "Ronald Reagan", 1981, 1989);
president [40] =new Presidents(41, "George H. W. Bush", 1989, 1993);
president [41] =new Presidents(42, "Bill Clinton", 1993, 2001);
president [42] =new Presidents(43, "George W. Bush", 2001, 2009);
president [43] =new Presidents(44, "Barack Obama", 2009, 2017);
president [44] =new Presidents(45, "Donald Trump", 2017, 2018);
return president;
}
}
不是import java.util.Scanner;
import java.util.Random;
public class PresidentsQuiz {
public static void main (String [] args)
{
System.out.println("Do you know the 45 presidents of the United States? Enter a number between 1 and 45");
Scanner kb = new Scanner (System.in);
int input = kb.nextInt();
while (input < 1 || input > 45)
{
System.out.println("Enter a number between 1 and 45");
input = kb.nextInt();
}
Presidents president = new Presidents ();
Presidents [] presidentList = president.PresidentList();
//System.out.println(presidentList [0].presidentName);
for(int i=0;i<input;i++)
{
Presidents p = presidentList[i];
System.out.println(p.presidentNumber+", "+p.presidentName+", "+p.startingYear+", "+p.endingYear);
}
kb.close();
}
}
(Run
),而在Mac中是Ctrl + R
。
也许您还有另一个键盘映射,请在Shift + F10
-> ^R
-> File
-> Settings
-> Keymap
-> {{1 }}。
答案 1 :(得分:0)
答案 2 :(得分:0)
您可以在以下位置更改绑定 首选项->键盘映射->主菜单->运行->运行
至于为什么^ R不起作用,您是否有机会使用IdeaVim插件?它会为重做获取^ R(通常是vim ^ R绑定),并且-不幸的是-IntelliJ键盘图中没有显示该指示。