java - 通过迭代二维数组返回一个对象
问题描述
在 Java 中,我创建了一个初始化的 2D 数组,表示一个有 15 排和每排 10 个座位的剧院:
Place[][] room = new Plaats[15][10];
现在我想遍历数组并返回对象 Plaats 以在其上调用方法。
private Place getPlaatObject(int rownumber, int seatnumber) {
Place places;
for (int row = 1; row < room.length; row++) { // loop by the rows
for (int seat = 1; seat < room[row].length; seat++) { // loop by the seats
return places;
}
}
}
我如何返回对象?
解决方案
推荐阅读
- python - 如何使用一个请求 DRF 创建多个对象
- python - 如何在 Web Scraping 中获取重定向的 URL?
- python - 如何思考 Python 的负数按位运算?
- apache-spark-sql - 在行中找不到“params.expo_cnt”的位置;这通常是由映射不一致引起的
- android - 听时在颤动中使用 Provider 的问题:true
- html - 如何使用 sed 删除 HTML 中的注释?
- swift - Swift 错误“类型‘BookingDataModel’不符合协议‘Decodable’”
- react-native - 反应原生:无法将自定义高度设置为模态
- python - ModuleNotFoundError:在使用 Anaconda 的 Windows 10 上没有名为“dlib”的模块
- php - 如何使用仅使用 for 循环的 PHP 程序方法在数据库中插入数组值