我想返回我的數組的值加上遞歸調用的返回值。Java說這個方法有一個構造函數名
但是由於某些原因,java不想在構造函數之後擁有方法名稱。
此外,當我試圖將該方法轉換爲另一種方法時,我得到錯誤,當我使用isPalindrome。
我改變我的程序,但我仍然收到錯誤。
public class isPalindrome
{
/**
* This is the main entry point for the application
* @return
*/
public static boolean main(String[] args)
{
String[] word = {"KayaK", "Desserts, I stressed"};
boolean isPalindrome(String[] array, String s, String i)
{
if(i.charAt(0) == s.charAt(0))
{
System.out.println("You entered a Palindrome");
return true;
}
else
{
System.out.println("You didn't entered a Palindrome");
}
}
try
{
System.in.read();
}
catch (Throwable t)
{
}
}
}
陣列應該表示什麼?主要你使用s作爲字符串數組,但isPalindrome似乎並沒有使用String數組作爲任何東西。 – 2011-03-02 03:48:09
這可能會有所幫助 - http://www.juggbread.com/2014/06/warning-this-method-has-constructor-name.html – 2014-08-28 17:47:09