public class AssignClass {
public static void main(String[] args) {
int numArr[] = {82,60,72,50,3,39,47,20}; //integer array
int smallTemp = numArr[0]; //assigning zeroth element as small number
int largeTemp = numArr[1]; //assigning first element as large number
for(int i=0; i<numArr.length;i++) //iterating till the end of the array
{
if(largeTemp<numArr[i]) //check if i'th value of array is large than largeTemp
{
largeTemp=numArr[i];
}
if(smallTemp>numArr[i]) //check if i'th value of array is small than largeTemp
{
smallTemp=numArr[i];
}
}
System.out.printf("Largest Number: %d\n", largeTemp); //print large number
System.out.printf("Smallest Number: %d\n", smallTemp); //print small number
}
}
printf用红色加下划线并给出错误?怎么了?我用过Eclipse
答案 0 :(得分:3)
printf
可用,所以看起来您的项目已配置为使用Java 1.4。右键单击项目更改项目配置,然后转到属性:
如果您碰巧在Java 8中创建项目,请确保您使用Eclipse Luna或Eclipse Kepler以及Java 8支持插件。 IMO我建议你使用Eclipse Luna。免责声明:我不是Eclipse的贡献者或任何其他基于Eclipse的技术,只是这个工具的快乐用户。