Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以将信息分配给java中数组中的元素?例如,我可以有一个包含标题和数字等的元素吗?你怎么办?谢谢
是的,与其拥有原始类型(如整数)或字符串的数组,不如定义您自己的类,然后创建一个数组。然后你可以在那里获得任何你想要的信息。
或者,如果数组必须是基元数组或字符串数组,因为某些其他方法要求它采用这种形式,您可以按需创建第二个数组,或者使用第二个数组来存储相关数据(同样,您可能为此创建自己的类)。