Karthikeya Boyini has Published 2383 Articles

CopyOnWriteArrayList Class in Java

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 14:41:11

4K+ Views

Class declarationpublic class CopyOnWriteArrayList    extends Object implements List, RandomAccess, Cloneable, SerializableCopyOnWriteArrayList is a thread-safe variant of ArrayList where operations which can change the ArrayList (add, update, set methods) creates a clone of the underlying array.CopyOnWriteArrayList is to be used in a Thread based environment where read operations are very ... Read More

Java program to find whether given character is vowel or consonant

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 14:27:51

6K+ Views

In English alphabet the characters 'a', 'e', 'i', 'o', 'u' are vowels and remaining letters are consonants. To find whether the given letter is a vowel or consonant.Using loop and or operator verify whether given character is 'a' or 'e' or 'i' or 'o' or 'u' else it is consonant.Exampleimport ... Read More

Database operations in Java

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 13:27:08

1K+ Views

This article provides an example of how to create a simple JDBC application. This will show you how to open a database connection, execute a SQL query, and display the results.Creating JDBC ApplicationThere are following six steps involved in building a JDBC application −Import the packages: Requires that you include ... Read More

Coupling in Java

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 13:22:22

4K+ Views

Coupling refers to the usage of an object by another object. It can also be termed as collaboration. This dependency of one object on another object to get some task done can be classified into the following two types −Tight coupling - When an object creates the object to be used, ... Read More

Counting number of paragraphs in text file using java

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 13:13:30

506 Views

We can read paragraphs in a file by reading it in a string and then spilting based on "\r" pattern. See the example below −ExampleConsider the following text file in the classpath.test.txtThis is Line 1 This is Line 2 This is Line 3 This is Line 4 This ... Read More

Counting number of characters in text file using java

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 13:10:12

5K+ Views

We can read characters in a file using BufferedReader class of Java. See the example below −ExampleConsider the following text file in the classpath.test.txtThis is Line 1 This is Line 2 This is Line 3 This is Line 4 This is Line 5 This is Line 6 This is Line ... Read More

Date Formatting Using SimpleDateFormat

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 12:43:03

786 Views

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.ExampleLive Demoimport java.util.*; import java.text.*; public class DateDemo {    public static void main(String args[]) {       Date dNow = ... Read More

Create gradient translucent windows in Java Swing

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 12:36:39

2K+ Views

With JDK 7, we can create a gradient based translucent window using swing very easily. Following are the steps needed to make a gradient-based translucent window. Make the background of JFrame transparent first.frame.setBackground(new Color(0, 0, 0, 0)); Create a gradient paint, and fill the panel.JPanel panel = new javax.swing.JPanel() {    protected ... Read More

Date Parsing using SimpleDateFormat

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 12:27:22

238 Views

The SimpleDateFormat class has parse() method, which tries to parse a string according to the format stored in the given SimpleDateFormat object.ExampleLive Demoimport java.util.*; import java.text.*;   public class DateDemo {    public static void main(String args[]) {       SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd");       ... Read More

C# program to find the sum of digits of a number using Recursion

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 12:13:42

235 Views

Let’s say we have set the number for which we will find the sum of digits −int val = 789; Console.WriteLine("Number:", val);The following will find the sum of digits by entering the number and checking it recursively −public int addFunc(int val) {    if (val != 0) {     ... Read More

Advertisements