天天看點

java對象數組删除_java-如何從數組對象中删除?符号并将其保...

我正在為大學項目編寫一個基本的聊天機器人.我認為使用者必須通過輸入金額來設定預算.目前,該程式可以在使用者的??消息中搜尋号碼并正确儲存.但是,如果在其前面加上英鎊符号,則由于消息中帶有英鎊符号,是以無法将其另存為整數.

這是我的代碼:

//Scan the user message for a budget amount and save it.

for (int budgetcount = 0; budgetcount < words.length; budgetcount++)

{

if (words[budgetcount].matches(".*\d+.*"))

{

if (words[budgetcount].matches("\u00A3."))

{

words[budgetcount].replace("£", "");

System.out.println("Tried to replace a pound sign");

ResponsesDAO.budget = Integer.parseInt(words[budgetcount]);

}

else

{

System.out.println("Can't find a pound sign here.");

}

}

我以前嘗試過.contains()以及其他訓示它是我要删除的英鎊符号的方法,但仍然得到“在這裡找不到英鎊符号”的資訊.列印.

如果有人可以提供建議或糾正我的代碼,我将不勝感激.

提前緻謝!