<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p><font face="Helvetica, Arial, sans-serif">openjdk 17.0.13
2024-10-15<br>
OpenJDK Runtime Environment (build 17.0.13+11-Debian-2deb12u1)<br>
OpenJDK 64-Bit Server VM (build 17.0.13+11-Debian-2deb12u1,
mixed mode, sharing)<br>
<br>
public class NamesRecord{<br>
String id;<br>
...<br>
// Setters and Getters<br>
public String getId(){<br>
return this.id;<br>
}<br>
}<br>
<br>
// Tres Dorritos Despues<br>
<br>
main(){<br>
// aoe.getAllNames() returns an ArrayList<NamesRecord>
object containing 13 elements<br>
// each element has a unique value<br>
var localArrayList = new
ArrayList<NamesRecord>(aoe.getAllNames());<br>
// Display all id values in NamesRecord <=== Only prints
one id NamesRecord::id value 13 times<br>
for(NamesRecord mydto : localArrayList){<br>
Integer pos = 1; <br>
System.out.print(pos + " ID is : ");<br>
System.err.print(mydto.getId() );<br>
pos++; // <== This value does not increment<br>
}<br>
<br>
// Second try, but same result<br>
for(int i = 10; i != localArrayList.size(); i++){<br>
System.out.print("\'i\' value is : ");<br>
System.err.println(i); // <== This value does
increment<br>
Integer pos = 1; <br>
System.out.print(pos + " ID is : ");<br>
System.err.println(localArrayList.get(i).getId() );<br>
pos++; // <== This value does not get incremented<br>
}<br>
<br>
// Third try, but the similar result<br>
// Please note that the value of pos is never incremented
<==<br>
NamesRecord[] array = new
NamesRecord[localArrayList.size()];<br>
array = localArrayList.toArray(array);<br>
for(NamesRecord mydto : array){<br>
Integer pos = 1;<br>
System.out.print(pos + " ID is : ");<br>
p.setTimer(1);<br>
System.err.println(mydto.getId() );<br>
pos++; // <== This value does not get incremented<br>
}<br>
}</font></p>
<p><font face="Helvetica, Arial, sans-serif">Hello.<br>
When looping through the ArrayList or even the Array[] to
display the content stored in NamesRecord::id only one value is
displayed; what I'd like to do is to display all the id values
stored in the ArrayList or Array[] object.<br>
However, as documented in the snip above, Java behaviour is not
what I expected; mind you, I am fairly new in Java.<br>
So, my question is, what am I doing wrong? <br>
If there is something wrong, would you point it out and help me
resolve it, please.<br>
</font></p>
<p><font face="Helvetica, Arial, sans-serif">Is it a bug that came
in the recent update I got from Debian?<br>
If so, how do I report the bug to OpenJDK?</font></p>
<p><font face="Helvetica, Arial, sans-serif">Thanks in advance.</font><br>
</p>
</body>
<lt-container></lt-container>
</html>