mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
add a new method
I add a method for manipulation individual fields.
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
* adds a row to the inner data structure.
|
||||
* without writing into the CSV-file.
|
||||
*
|
||||
* set (row : int, column : int, item : string) : void
|
||||
* replaces the specified item with a newer.
|
||||
*
|
||||
* commit() : void
|
||||
* writes the added data into CSV-file.
|
||||
*
|
||||
@@ -711,4 +714,24 @@ public class CSVFile {
|
||||
return table.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param row
|
||||
* @param column
|
||||
* @param item
|
||||
* @purpose replaces the specified item with a newer.
|
||||
*/
|
||||
public void set(int row, int column, String item) {
|
||||
if (row < table.size()) {
|
||||
if (column < table.get(row).size()) {
|
||||
table.get(row).set(column, item);
|
||||
} else {
|
||||
throw new RuntimeException("set: column is too large!");
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("set: row is too large!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user