我是新来的,所以如果我的问题错了,请告诉我,我会事先道歉。
我创建了一个程序,用于获取用户输入,将其放入数组,然后反转数组并检查回文。然后程序将从101打印回文到用户输入号码。现在我只想检查我为反转数组创建的循环是否正常工作,但是当我调用该方法时,我得到了错误
"method reverseArray in class Palindrome cannot be applied to given types"
required: char[]
found: no arguments
reason: actual and formal arguments differ in length
这是代码(现在底部的三种方法都是空的,因为我还没有编写它们。)
public static void main(String[] args)
{
Scanner promptUser = new Scanner(System.in);
System.out.print("Enter an Integer greater than 100: ");
Integer userInt = new Integer(promptUser.nextInt());
String userString = userInt.toString();
char[] charUser = userString.toCharArray();
if (userInt <= 100)
{
System.out.print("That integer is not greater than 100,"
+ " restart program and try again!");
}
System.out.println(reverseArray());
}
/**Takes the integer provided by the user and turns it into a string
* then takes that string and puts it into a char[], then there is a for loop
* to reverse that array.
* @param userArray array used to store the reversed string.
* @revArray char array used to store data from charChange array.
* @return returns charChange now with the reversed string.
*/
public static char[] reverseArray(char[] userArray)
{
char[] revArray = new char[userArray.length];
for(int i = 0; i < revArray.length; i++)
{
userArray[i] = revArray[revArray.length - 1 - i];
}
return userArray;
}
public static boolean arraysAreEqual(char[] arrayPal1, char[] arrayPal2)
{
}
public static boolean isPrime(int Primes)
{
}
public void printArray(char[] charChange)
{
}