Arrays.asList in Java Examples

We generally use Arrays.asList method to copy an object array into a List object. It returns a fixed-size List object from the object array that you have passed to this method. Since Arrays.asList method returns a fixed-size List object, you must remember that you cannot add or remove elements from this List object as you … Read more

[Solved] Why List.add throws UnsupportedOperationException in Java?

If you are getting an UnsupportedOperationException while adding an object to List the reason could be that you are performing this operation on a fixed-size List object. What is a fixed-length object? You must have used Arrays.asList method to convert an array object to List object. If you closely look at the documentation of Arrays.asList … Read more

How to Convert an Array to List in Java?

Though an array is an object in Java, it doesn’t have the required methods to convert it to a List object, it just contains the basic methods that it derived from the Object class. But if you want to convert an array to List, we have other alternatives. Using Arrays.asList(Object[]) Arrays.asList method can take an … Read more

How Many Spaces in a Tab?

I always wonder, what if there was no tab key on the keyboard, how the world would have been? I pity on those people who don’t know about this wonder key and still use spacebar to beautify their work. So, now you recognized the power and wondering how many spaces are there in a tab? … Read more