Found 2616 Articles for Java

Java Program to compare dates if a date is after another date

karthikeya Boyini
Updated on 10-Aug-2023 12:57:20

578 Views

In the world of Java programming, there are a few scenarios where we are required to deal with the date and time such as while developing a calendar application, attendance management system in Java and checking age of two persons. Also, the date is a way of keeping track of our time as it is an integral part of our daily lives. Therefore, Java provides classes like Date and LocalDate to work with date and time. And, to compare and check if a date is after another or not, it provides a few useful built-in methods like 'compareTo()' and 'after()'. ... Read More

Java Program to check the beginning of a string

Samual Sam
Updated on 10-Aug-2023 12:52:28

158 Views

A string is a class in Java that stores a series of characters enclosed within double quotes. Those characters are actually String-type objects. The string class is available in the 'java.lang' package. Suppose we have given a string and our task is to find the beginning of that string. Let's assume the beginning as the first two or three characters of that string. To check the beginning of a string, we can use several built-in methods available in Java including substring() and charAt(). Java Program to Check the Beginning of a String To check the beginning of a string we ... Read More

Java program to check if string is pangram

karthikeya Boyini
Updated on 27-Jun-2024 17:51:16

7K+ Views

A pangram is a string that contains all the letters of the English alphabet. An example of a pangram is "The quick brown fox jumps over the lazy dog". Problem Statement Given a string, write a Java program to check whether it is pangram or not.Consider the following example - Input The quick brown fox jumps over the lazy dog. Output String: The quick brown fox jumps over the lazy dog. The above string is a pangram. Algorithm The algorithm below is focusing to check if the string is pangram. Step 1: Create a boolean array `alphaList` ... Read More

Java program to count words in a given string

karthikeya Boyini
Updated on 31-May-2024 12:58:51

13K+ Views

A string is a class in Java that stores a series of characters enclosed within double quotes. Those characters act as String-type objects. The aim of this article is to write Java programs that count words in a given string. Counting words of the given strings can be solved using the string manipulation techniques. In Java interviews, questions from string manipulation are very frequent, hence, it is important to understand this problem properly. Java Program to Count Words in a given String Before jumping to the example programs, let's understand the problem statement with the help of an example. Input ... Read More

Java Program to convert a String to int

karthikeya Boyini
Updated on 10-Aug-2023 13:06:22

287 Views

To convert a String to int in Java, we can use the two built-in methods namely parseInt() and valueOf(). These static methods belong to the Integer class of java.lang package and throws a NumberFormatException if the string is not a valid representation of an integer. In Java, String is a class of 'java.lang' package that stores a series of characters enclosed within double quotes. And, an integer is a primitive datatype that stores numerical values. In this article, we will discuss a few Java programs that illustrate how to convert a given String to integer. Java Program to Convert a ... Read More

Java and multiple inheritance

Arjun Thakur
Updated on 10-Aug-2023 12:01:11

7K+ Views

In Java, we use inheritance to allow the creation of a hierarchical classification of classes and objects. As the name suggests, inheritance is the ability of a class to inherit members of another class. The class whose properties are inherited is called a superclass whereas the class that inherits a superclass is called a subclass. We use the extends keyword to inherit the class. There are several types of inheritance in Java such as single and multilevel. In this article, we will specifically explore the multiple inheritance. Multiple Inheritance in Java In the terminology of object-oriented programming, multiple inheritance is ... Read More

Comparison of Java and .NET

Samual Sam
Updated on 30-Jul-2019 22:30:23

249 Views

Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. .NET framework is a computer software framework invented by Microsoft. It runs on Microsoft Windows OS (Operating Systems). It provides user interface, data access, database connectivity, cryptography, web application development, etc. Languages Java supports only Java patterns. .NET supports multiple languages such as VB.NET, C#, F#, etc. Platforms Java is platform independent and it can run on Windows, Linux and Mac OS. .NET works on Windows. Runtime ... Read More

Why Java programs running on Android systems do not use the standard Java API and virtual machine?

David Meador
Updated on 22-Jun-2020 15:09:37

523 Views

The standard Java API and virtual machine are mainly designed for desktop as well as server systems. They are not that compatible with mobile devices. Because of this, Google has created a different API and virtual machine for mobile devices. This is known as the Dalvik virtual machine.The Dalvik virtual machine is a key component of the Android runtime and is a part of JVM (Java Virtual Machine) developed specially for Android. The Dalvik virtual machine uses features that are quite important in Java such as memory management, multi-threading etc. The programs in Java are first converted into JVM and ... Read More

Can we overload or override a static method in Java?

karthikeya Boyini
Updated on 01-Dec-2023 11:49:35

3K+ Views

If a class has multiple functions by the same name but different parameters, it is known as Method Overloading. If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding. Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its superclass parameter must be different in case of overloading, the parameter must be same in case of overriding. Now considering the case of static methods, then static methods have following rules in terms of overloading and ... Read More

Difference between Object and Class in Java

Kiran Kumar Panigrahi
Updated on 23-Jun-2023 13:45:54

1K+ Views

Classes and objects are considered as the building blocks of object-oriented programming. Every entity with state and behavior is an object. Collection of these similar kinds of objects is a class. A class can be only accessed by its objects hence securing data in it. Read this article to learn more about objects and classes in Java and how they are different from each other. What are Classes in Java? A class is a user-defined data type that acts as a blueprint for designing the objects in it. It is said to be a container that stores objects of similar ... Read More

Advertisements