Arjun Thakur has Published 1109 Articles

Local inner class in Java

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:38:35

2K+ Views

In Java, just like methods, variables of a class too can have another class as its member. Writing a class within another is allowed in Java. The class written within is called the nested class, and the class that holds the inner class is called the outer class.SyntaxFollowing is the ... Read More

Copy Elements of One ArrayList to Another ArrayList with Java Collections Class

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:38:08

8K+ Views

In order to copy elements of ArrayList to another ArrayList, we use the Collections.copy() method. It is used to copy all elements of a collection into another.Declaration −The java.util.Collections.copy() method is declared as follows −public static void copy(List

Get Enumeration over ArrayList with Java Collections

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:36:46

451 Views

In order to get enumeration over ArrayList with Java Collections, we use the java.util.Collections.enumeration() method.Declaration −The java.util.Collections.enumeration() method is declared is as follows −public static Enumeration enumeration(Collection c)where c is the collection object for which an enumeration is returnedLet us see a program to get enumeration over ArrayList −Example Live ... Read More

Replace all occurrences of specified element of ArrayList with Java Collections

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:34:24

1K+ Views

In order to replace all occurrences of specified element of ArrayList with Java Collections, we use the Collections.replaceAll() method. This method returns true if list contains one or more elements e such that (oldVal==null ? e==null : oldVal.equals(e)).Declaration −The java.util.Collections.replaceAll() is declared as follows −public static boolean replaceAll(List list, ... Read More

Multithreading in Java

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:32:18

437 Views

Java is a multi-threaded programming language which means we can develop multi-threaded program using Java. A multi-threaded program contains two or more parts that can run concurrently and each part can handle a different task at the same time making optimal use of the available resources specially when your computer ... Read More

Unix style pathname pattern expansion in Python (glob)

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:28:31

413 Views

Many a times a program needs to iterate through a list of files in the file system, often with names matching a pattern. The glob module is useful in creating lit of files in specific directory, having a certain extension, or with a certain string as a part of file ... Read More

Java Program to convert first character uppercase in a sentence

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:25:48

531 Views

In order to convert first character as upper case in a sentence we have to first separate each word of sentence and then make first character of each word in upper case.After which we have to again join each word separated by space to make again sentence.Now let take each ... Read More

Java program without making class

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:23:05

460 Views

Is it possible to create and run a Java program without any class? The answer is Yes. Trick is to use enum instead of Class. Although enum is used to represent public static constant. It can have static main method as well. See the example below −Example Live Demopublic enum Tester ... Read More

Generate temporary files and directories using Python

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:21:25

14K+ Views

The tempfile module in standard library defines functions for creating temporary files and directories. They are created in special temp directories that are defined by operating system file systems. For example, under Windows the temp folder resides in profile/AppData/Local/Temp while in linux the temporary files are held in /tmp directory.Following ... Read More

Lambda expression in Java 8

Arjun Thakur

Arjun Thakur

Updated on 25-Jun-2020 14:17:55

397 Views

Lambda expressions are introduced in Java 8 and are touted to be the biggest feature of Java 8. Lambda expression facilitates functional programming, and simplifies the development a lot.SyntaxA lambda expression is characterized by the following syntax.parameter -> expression bodyFollowing are the important characteristics of a lambda expression.Optional type declaration ... Read More

Advertisements