hbitteur opened a new issue, #4824:
URL: https://github.com/apache/netbeans/issues/4824
### Apache NetBeans version
Apache NetBeans 15
### What happened
A collection declared as `final` can be added to and read from, and the
program works correctly of course.
However Netbeans flags this collection with the warning "_**The collection
is only added to, never read**_"!
See the simple example below.
### How to reproduce
```
public void test ()
{
final List<String> myList = new ArrayList<>(); // Line 1, warning here
myList.add("FooBar"); // Line 2, where addition is done
for (String str : myList) { // Line 3, where reading is done
System.out.println(str);
}
}
```
Netbeans flags line 1 with the warning message: "_The collection is only
added to, never read_"
Warning is wrong, since the collection is read on line 3.
This false warning disappears when `final` is removed on line 1.
It disappears also if line 2 (addition) is removed.
### Did this work correctly in an earlier version?
Apache NetBeans 12.6 or earlier
### Operating System
Windows 10, 64 bits
### JDK
17.0.2
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
_No response_
### Are you willing to submit a pull request?
No
### Code of Conduct
Yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists