Java Articles

Page 167 of 450

Duodecimal in java

Ashin Vincent
Ashin Vincent
Updated on 28-Feb-2025 323 Views

The duodecimal number system is also known as the base-12 number system. The decimal system (base-12) uses digits 0-9, while the duodecimal system uses digits 0-9 along with two additional symbols, A and B. In duodecimal, 10 represents 12 , which means 12 in the decimal number system is 10 in the duodecimal system. We often encounter duodecimal in daily life; for example, we have 12 months in a year, 12 zodiac signs, 12 inches in a foot, 12 musical notes in an octave, and we call a group of 12 items a dozen. Representation of duodecimal numbers The duodecimal ...

Read More

Difference Between JDK and BlueJ

Ashin Vincent
Ashin Vincent
Updated on 28-Feb-2025 421 Views

JDK (Java Development Kit) is a software development kit that contains all the necessary tools and components that are essential to develop a Java application. Whereas BlueJ is an IDE that will make the process of developing a Java application a lot easier. BlueJ requires JDK installed on the system to work with Java applications. Java Development Kit (JDK) The Java Development Kit (JDK) contains all the essential libraries, tools, and all other important things to work with Java. You can’t do programming in Java without JDK. The modern IDEs, like "IntelliJ IDEA" will already be equipped with Java essential ...

Read More

Checking if Two Words Are Present in a String in Java

Ashin Vincent
Ashin Vincent
Updated on 28-Feb-2025 491 Views

In this article, we will learn how to check if two given words are present in a string. This is useful when you need to check for multiple words in the text for different purposes, like searching, filtering, or text analysis. We will explore different approaches on how to implement it in Java, starting from the simple method to more advanced techniques. Example Scenario Consider this string: "Java provides powerful libraries for developers." We want to check if both "java" and "libraries" appear in the text. In this case, the output will be true. 1.Using contains() The contains() method checks ...

Read More

Can a final class be subclassed in Java?

Alshifa Hasnain
Alshifa Hasnain
Updated on 27-Feb-2025 2K+ Views

In Java Inheritance is a fundamental feature that allows a class to derive properties and behaviors from another class. In Java, not all classes can be subclassed. A final class is a special type of class that cannot be extended.  What is a Final Class in Java? In Java, a class is declared final using the final keyword. The final modifier for finalizing the implementations of classes, methods, and variables. When a class is marked as final, it means − It cannot be extended. All its methods remain unchanged in their ...

Read More

How to declare a local variable in Java?

Alshifa Hasnain
Alshifa Hasnain
Updated on 27-Feb-2025 1K+ Views

In Java, local variables are those that have been declared within a method, constructor, and block, and are only accessible within that defined scope. Such local variables are used when there is a need to store temporary data during the execution of a program. What is a Local Variable? Local variables are declared in methods, constructors, or blocks. Local variables are created when the method, constructor, or block is entered and the variable will be destroyed once it exits the method, constructor, or block. A local variable is a variable that is − Declared inside ...

Read More

Java ResultSetMetaData getScale() method with example

Alshifa Hasnain
Alshifa Hasnain
Updated on 27-Feb-2025 607 Views

In this article, we will learn the ResultSetMetaData getScale() method in Java. The ResultSetMetaData interface provides metadata about the columns in a ResultSet object. The getScale() method returns the number of digits to the right of the decimal point for a specified column. What is the getScale() method? The getScale() method of the ResultSetMetaData (interface) retrieves the number of digits after the right of the decimal point in the given column. This method accepts an integer value representing the index of a column. and returns an integer value representing the number of digits after the decimal in the specified column. Syntax ...

Read More

Java DatabaseMetaData getDriverName() method with example

Alshifa Hasnain
Alshifa Hasnain
Updated on 27-Feb-2025 503 Views

In this article, we will learn about the DatabaseMetaData getDriverName() method in Java. The DatabaseMetaData interface provides useful methods to obtain details about the database and the JDBC driver. One such method is getDriverName(), which returns the name of the JDBC driver being used. What is getDriverName() in Java? The getDriverName() method belongs to the DatabaseMetaData interface in Java's JDBC API. It retrieves the name of the JDBC driver currently connected to the database. Syntax String driver_name = metaData.getDriverName(); The method returns the following values − Returns a String representing the name of the ...

Read More

Java Program to Find Two Elements Whose Sum is Closest to Zero

Ashin Vincent
Ashin Vincent
Updated on 27-Feb-2025 312 Views

In this article we will learn how to find the two elements in an array whose sum is closest to zero. The array can contain both positive and negative values as well. Let's understand with the help of an example. Example Let's take an array with the following elements − arr = {3, -56, -76, -32, 45, 77, -14, 13, 92, 37} Here, two elements whose sum is closest to zero are 77 and -76, and their sum is 1. Note: In this example we have 77 and -76, which will give the sum as 1, and also ...

Read More

Length of the longest consecutive zeroes in the binary representation of a number in java

Ashin Vincent
Ashin Vincent
Updated on 27-Feb-2025 318 Views

You are given a number (N); you need to find the length of the longest consecutive zeroes in the binary representation of the number using different approaches. Example Input N = 529 The binary form of 529 is 1000010001. Output The longest chain of zeroes in the binary form is 0000 with a length of 4. Hence, the answer is 4. Approach 1: Using Division and Modulus In this approach we use division and modulus operations to convert decimal to binary and then count the maximum zeroes in the binary number. Steps for implementation The following steps explain ...

Read More

Lead Number in java

Ashin Vincent
Ashin Vincent
Updated on 27-Feb-2025 1K+ Views

A lead number is a number whose sum of even digits is equal to the sum of odd digits. In this article, we will learn about lead numbers and programs to check if a number is a lead number or not. Lead number example Let’s take the number 615341. The sum of even digits is 6 + 4 = 10. The sum of odd digits is 1 + 5 + 3 + 1 = 10. Here, the sum of even digits = the sum of odd digits, so 615341 is a lead number Arithmetic Approach This approach extracts digits ...

Read More
Showing 1661–1670 of 4,498 articles
« Prev 1 165 166 167 168 169 450 Next »
Advertisements