karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 82 of 143

What are annotations in Java?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 976 Views

Annotations are a tag (metadata) which provides info about a program. Annotations in Java Start with the symbol ‘@’. They are used by the compiler to detect errors. Software tools to generate code. They are used to show attributes of an element: e.g. @Deprecated, @Override. Annotation are used to describe the purpose of an element of the framework, e.g. @Entity, @TestCase, @WebService Annotations describe the behaviour of an element: @Statefull, @Transaction. Example class Sample{ public void display(){ System.out.println(" "); } } public class Test extends ...

Read More

What's the simplest way to print a Java array?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 247 Views

Generally, to print the contents of an array you need to use for loops, in addition to that you can directly print an array using the toString() method of this class. This method accepts an array as a parameter and returns it in String format.Exampleimport java.util.Arrays; public class PrintingArrays {    public static void main(String args[]) {       int[] myArray = {23, 93, 30, 56, 92, 39};       System.out.println(Arrays.toString(myArray));    } }Output[23, 93, 30, 56, 92, 39]

Read More

Java Program to count letters in a String

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 21K+ Views

Let’s say we have the following string, that has some letters and numbers.String str = "9as78";Now loop through the length of this string and use the Character.isLetter() method. Within that, use the charAt() method to check for each character/ number in the string.for (int i = 0; i < str.length(); i++) {    if (Character.isLetter(str.charAt(i)))    count++; }We have set a count variable above to get the length of the letters in the string.Here’s the complete example.Examplepublic class Demo {    public static void main(String []args) {       String str = "9as78";       int count = ...

Read More

Java Program to convert ASCII code to String

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 18K+ Views

To convert ASCII to string, use the toString() method. Using this method will return the associated character.Let’s say we have the following int value, which works as ASCII for us.int asciiVal = 89;Now, use the toString() method.String str = new Character((char) asciiVal).toString();Examplepublic class Demo {    public static void main(String []args) {       int asciiVal = 87;       String str = new Character((char) asciiVal).toString();       System.out.println(str);    } }OutputW

Read More

Split String with Comma (,) in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 34K+ Views

Let’s say the following is our string.String str = " This is demo text, and demo line!";To split a string with comma, use the split() method in Java.str.split("[,]", 0);The following is the complete example.Examplepublic class Demo {     public static void main(String[] args) {        String str = "This is demo text, and demo line!";        String[] res = str.split("[,]", 0);        for(String myStr: res) {           System.out.println(myStr);        }     } }OutputThis is demo text and demo line!

Read More

How to convert Javascript dictionary to Python dictionary?

karthikeya Boyini
karthikeya Boyini
Updated on 01-Sep-2025 2K+ Views

Python Dictionary In Python, a dictionary is a collection of unique key-value pairs. Unlike lists, which use numeric indexing, dictionaries use immutable keys like strings, numbers, or tuples. Lists cannot be keys since they are mutable. Dictionaries are created using {} and store, retrieve, or delete values using their keys. The list() function returns all keys, sorting them. The in keyword checks for key existence, and replacing a key updates its value. Converting JavaScript to a Python Dictionary Python and JavaScript represent dictionaries differently, so an intermediate format is needed to exchange data between them. The most widely used format ...

Read More

Get the union of two sets in Java

karthikeya Boyini
karthikeya Boyini
Updated on 28-Jan-2025 7K+ Views

The union of two sets combines all the unique elements from both sets into one. In Java we can achieve this using the HashSet class, which ensures no duplicate elements. This article will demonstrate two approaches to finding the union of two sets.  Different Approaches  Following are the two different approaches to getting the union of two sets in Java − Using the addAll() Method Using Streams Using the addAll() Method The simplest way to find the union of two sets is by using the addAll() method of the HashSet class. This ...

Read More

Java Program to display Frame after some seconds

karthikeya Boyini
karthikeya Boyini
Updated on 02-Jan-2025 513 Views

In this article, we will learn how to display a frame after a few seconds in Java using the Timer class. This example shows how to delay the visibility of a frame by 2 seconds using Swing. Timer() class The Timer class is used to schedule tasks that execute after a specific time interval or repeatedly at regular intervals. It allows tasks to be run by a thread that handles the scheduling and execution. Each task can be set to execute either once or repeatedly at fixed intervals. The execution of all tasks is managed by a background thread associated ...

Read More

Java program to convert a Map to a read only map

karthikeya Boyini
karthikeya Boyini
Updated on 31-Dec-2024 741 Views

A read-only map in Java is a type of Map that cannot be modified after it has been created. This means that once the map has been set to be read-only, we cannot add, remove, or update any of the key-value pairs.Converting a Map to a read only map We can convert a mutable map to an immutable map, a read-only map using the Collections.unmodifiableMap() method. This method provides a way to make sure that the map cannot be modified once it has been wrapped in this method. Following are the steps to convert a Map to a read-only map ...

Read More

Java Program to convert from a java.util.Date Object to a java.sql.Date Object

karthikeya Boyini
karthikeya Boyini
Updated on 23-Dec-2024 777 Views

In this article, we will learn to convert a java.util.Date object to a java.sql.Date object in Java. This is a common requirement when working with databases, as many database systems use the java.sql.Date class to represent date values. While java.util.Date is used for general date and time representation in Java, java.sql.Date is specifically designed to handle SQL-compatible date formats. java.util.Date  The Date class in the java.util package representing a specific moment in time, measured in milliseconds since January 1, 1970, UTC (the "epoch"). It's a general-purpose date and time representation. java.sql.Date A subclass of ...

Read More
Showing 811–820 of 1,421 articles
« Prev 1 80 81 82 83 84 143 Next »
Advertisements