418
Subscribers
No data24 hours
-27 days
+1230 days
Posts Archive
==============================
Java 10 feature
==============================
List.copyOf() method
Java 10 introduced a new method called List.copyOf(). This method creates and unmodifiable copy of an existing list, meaning you can't change the list after you create it. This is useful when you want to share a list with others parts of your program, but ensure that the list cannot be modified.
Key Points
============
Immutable copy : List.copyOf() creates a list that cannot be changed.
Shallow copy : The elements themselves are not copied; only their references are.
No Null Elements : The original list cannot containe null elements.
Read only : Attempting to modify the list will result in an error.
How to Use List.copyOf()
To create an unmodifiable list, you can use the List.copyOf() method and pass and existing list to it.
SYNTAX
===========
List<Type> unmodifiable = List.copyOf(originalList);
Here originalList is the list you want to copy, and unmodifiableList is the new list that cannot be modified.
Java 10 features
List.copyOf() method
Java 10 introduced a new method called List.copyOf(). This method creates and unmodifiable copy of an existing list, meaning you can't change the list after you create it. This is useful when you want to share a list with others parts of your program, but
Java Quiz π§π»βπ»
==============
Can constructors in Java be overloadedβ
A) Yes
B) No
Comment Correct Option β¬οΈ
Java Quiz π§π»βπ»
==============
Is it possible to overload a method by changing only its return type β
A) Yes
B) No
Comment Correct Option β¬οΈ
Java Quiz π§π»βπ»
Can overloaded methods have different return types in Java β
A) Yes
B) No
Comment Correct Option β¬οΈ
In which Java version was the module system introducedβ
10 beginner level projects
Sabhi start krdo projects bnana or projects ke sath sath chize sikhte rheo
public class Main()
{
public static void main(String args[])
{
System.out.println(0.0/0);
}
}
What is the output β¬οΈ
A) Arithmetic Exception
B) Compilation Error
C)NaN
D)0
Comment Down ππ»ππ»
Order of execution of constructors in Java inheritance is β
