我已經創建了一個2d數組,我需要在該數組中搜索狀態縮寫,如果找到,那麼我需要打印它發現的行。我確實爲此創建了一個單獨的方法。我正在傳遞一個兩字母狀態縮寫,我在我的主要要求。我已經搜索了其他論壇,但是我看到的所有問題都與這類問題有關。我發現的很多東西都是爲了找到重複的東西,或者如果發現打印索引,而不是行。感謝任何幫助。搜索一個元素的二維數組(Java)
private static void ticketpayout(String state) {
// search array for state
//2d array with all state info
String[][] tax = {
{"AZ", "5%", "Annually", "$2,823,333", "After 30 Years", "$84,699,990", "Cash", "$57,050,000"},
{"AR", "7%", "Annually", "$2,742,667", "After 30 Years", "$82,280,010", "Cash", "$55,420,000"},
{"CO", "4%", "Annually", "$2,863,667", "After 30 Years", "$85,910,010", "Cash", "$57,865,000"},
{"CT", "6.7%", "Annually", "$2,754,767", "After 30 Years", "$82,643,010", "Cash", "$55,664,500"},
{"DE", "0%", "Annually", "$3,025,000", "After 30 Years", "$90,750,000", "Cash", "$61,125,000"},
{"FL", "0%", "Annually", "$3,025,000", "After 30 Years", "$90,750,000", "Cash", "$61,125,000"},
{"GA", "6%", "Annually", "$2,783,000", "After 30 Years", "$83,490,000", "Cash", "$56,235,000"},
{"ID", "7.8% ", "Annually", "$2,710,400", "After 30 Years", "$81,312,000", "Cash", "$54,768,000"},
{"IL", "5%", "Annually", "$2,823,333", "After 30 Years", "$84,699,990", "Cash", "$57,050,000"},
};
}
你試過了什麼循環? – Randy 2012-07-25 13:42:25
您作爲方法的參數傳遞的狀態僅由兩個或更多字母定義? – 2012-07-25 13:43:55
歡迎來到Stackoverflow。請編輯您的問題,以包含您迄今爲止編寫的搜索方法。 – mikej 2012-07-25 13:44:42