본문 바로가기

Language93

Arrays.asList() vs ArrayList 'Arrays.asList()' and 'ArrayList' are both related to the Java Collections Framework and are used to store and manipulate collections of objects. However, there are some key differences between them. 1. Type of Collection : 'Arrays.asList()' : It returns a fixed-size 'List' backed by an array. They underlying array cannot be resized, and any attempt to modify the size of the list will result in .. 2023. 6. 19.
Lambda expressions In Java, lambda expressions are a feature introduced in Java 8 that allow you to write more concise and expressive code when working with functional interfaces. Lambda expressions are essentially anonymous functions that can be used as a replacement for single-method interfaces. They provide a way to define a behavior or an implementation directly at the point of use without explicitly implement.. 2023. 6. 16.
Anonymous class In Java, an anonymous class is a class that is declared and instantiated in a single expression, without providing a separate class definition. It is typically used when you need to create a class that implements an interface or extends a class, but you don't need to reuse the class elsewhere in your code. Here's the general syntax for creating an anonymous class : interface MyInterface { void d.. 2023. 6. 14.
Array and ArrayList Both Array and ArrayList are used to store elements, which can be either primitives or objects in Java. 1. Size Array : The size of an array is static. Once an array is created, Its size can't be changed. You need to know the size of the array at the time of creation. ArrayList : An ArrayList is dynamic. It can grow or shrink dynamically as the elements are added or removed. 2. Type of elements .. 2023. 5. 30.