Assuming I have an ArrayList ArrayLists created this way:
ArrayList< ArrayList<String> > listOfListsOfStrings = new ArrayList< ArrayList<String> >();
If I call:
listOfListsOfStrings.clear();
Will an attempt to access any of the lines inside listOfListsOfStrings later always result in a java.lang.NullPointerException error?
No, only links will be cleared. If the reference to the object no longer exists, it may be garbage collection, but you will not receive NPE, since then you have no way to get a new reference to this object.
No, it will not delete objects in an ArrayList if you still have external references to them. ArrayList.clear () does nothing for the objects referenced unless they are orphans, in which case you will not reference them later.
ArrayList
Source: https://habr.com/ru/post/885939/More articles:Subclassing a set of interdependent classes in Objective-C and ensuring type safety - overrideWPF ComboBox in DataGrid databinding / update not working - .netNSAttributedString kCTParagraphStyleSpecifierParagraphSpacing not affected - iosForce scientific notation in tick marks ListLogLogPlot - wolfram-mathematicaLine spacing and alignment in CoreText - iphoneCross-platform communication Serial port in Java? - javaAccess to custom font from Jar - javaEclipse app for Android: run with a real certificate - androidDisplay the on-screen keyboard if the user sets focus to the text field. WPF with .Net 4 Client Profile - windows-7Drag and drop to custom task pane in Excel VSTO - c #All Articles