Found 7442 Articles for Java

Java Program to Illustrate the usage of Octal Integer

Sakshi Ghosh
Updated on 12-Apr-2023 12:30:06

245 Views

Octal Integer is a number system having a base of 8 and digits from 0 to 7. Int data type is taken into account to store an octal number. The usage of the Octal number system is to be discussed here − Converting decimal to Octal Converting octal to decimal. Conversion from a Decimal number system to an Octal Number system Basics of Conversion To convert any decimal number into its equivalent octal number: Keep dividing the decimal number by the base of the octal number system which is 8 till the quotient 0 is received. Remember ... Read More

Java program to solve set cover problem

Rudradev Das
Updated on 11-Nov-2024 19:16:40

643 Views

The set covering is a well-known NP-hard problem in the combinational optimization technique. We call the set cover problem NP-Hard because there is no polynomial real-time solution available for this particular problem. An algorithm called greedy heuristic is a well-known process for the set cover problem. Here is an example − Let U be the universe of elements, {S1, S2, .....Sm} be collection of subsets of the set, U and Cost(S1), C(S2), ......Cost(Sm) be costs of subsets. 1)Let I is the set of elements included so far. Initialize the process I = {} 2) Do following ... Read More

Java Program to Shuffle Vector Elements

Rudradev Das
Updated on 12-Apr-2023 17:06:51

223 Views

Shuffle() is collection class method in Java, works in a random manner based on the permutation logic on a specific group of list elements. Tree are two distinct types of method in a shuffle class(), depending on the particular parameters. Java Collections shuffle(list) Method. Java Collections shuffle(list, random) Method. In this method, we can arrange the characters randomly to generate some random values. Then we will apply the suffle method on it. To perform the vector shuffle, we can use Fisher-Yates shuffle algorithm. In this method, we can learn a linear scan on a vector and swap each ... Read More

Java Program to Show Time By Rolling Through Hours and Months

Rudradev Das
Updated on 12-Apr-2023 17:04:57

162 Views

The credibility of an efficient coding language depends upon how well it can manage the date and time. In a Java Virtual Environment we get some inbuilt facilities like date, time and calendar to handle the problem related to date and time. java. until date class - In Java, there are many contains those are very important for the program. Date class deals with the operation about the date and time. They are those type of classes which comes with the feature of cloneable, Serializable and comparable interfaces. Extract the current date and time - There are two types ... Read More

Java Program to show the Nesting of Methods

Rudradev Das
Updated on 13-Apr-2023 11:58:33

6K+ Views

Nesting of methods is a hybrid function calling method in Java, which can call another method in the same class. There are two types of nested classes are available in a Java environment. Non-static nested class (also known as , the inner class) Static nested class A non-static nested class (or, inner class) is a defined class within a particular class. It also contains some outer classes with some access authorities. In this method, we can use "." operator to create the instance of the inner class by using an outer class. On the other hand; a static ... Read More

Java Program to Segregate 0s on Left Side & 1s on Right Side of the Array

Rudradev Das
Updated on 06-Aug-2024 22:37:14

2K+ Views

Segregation is a process in the field of software engineering where a code is forced to depend on those methods that are not in use. The segregation interface is known as ISP. It splits the interfaces that are vast in nature. In a Java environment, there are lots of advantages to implementing the segregation principle. It increases the readability of the particular code. It also helps to maintain that particular code conveniently. Problem Statement There is an array of 7s and 16s aimlessly. We must segregate the 7s on the left side and the 16s on the right. The basic ... Read More

Java Program to Search User Defined Object From a List By using Binary Search Comparator

Rudradev Das
Updated on 11-Apr-2023 15:49:36

335 Views

Java comparator interface used to sort Java objects. A comparator class in Java compares the different objects (Obj 01, Obj 02) by invoking the "java. util. comparator". In this method the objects can be compared on the basis of the return value. It can be positive, equal or negative in comparison. The process provides user multiple sorting sequences. There are lots of method by which we can perform the comparison between two methods. public int compare class (obj 1, obj 2) - Perform comparison between two objects. public Boolean equals (obj) - Compare current object with specified object. ... Read More

Code Solution to sword puzzle

Vaishnavi Tripathi
Updated on 09-Feb-2024 16:22:38

457 Views

We will discuss two approaches to solve the sword puzzle. In the first approach, we will use circular linked list, while the second approach is based on general intuition. In this article, we will discuss what is a sword puzzle problem and how we can solve a sword puzzle problem. Problem Statement We have an arrangement of n people in a circle in which, first person is carrying a sword. The first person kills the second person and hands over the sword to the next alive person in the circle. Now the next person carrying the sword kills the next ... Read More

Java Program to Represent Linear Equations in Matrix Form

Rudradev Das
Updated on 23-Nov-2024 03:44:51

589 Views

In this segment of Java programming, we are going to learn and discover certain programs by which we can represent linear equations in Matrix form. To do these programs, we first have to learn about linear equations and Matrix forms, their types, and how they are solved by simple mathematical methods. We will learn how to integrate a scanner class of java.util package to take input from the user using Java build code. The array will initialize to store some variables as input for the problem matrix. Then, it will be converted into a loop by which the problem equation will ... Read More

Java Program to Illustrate a Method without Parameters but with Return Type

Sakshi Ghosh
Updated on 26-Dec-2024 20:46:37

5K+ Views

In Java, a method is a block of code that performs a specific task. Methods can take zero or more parameters and can also return a value. When a method returns a value, we call it a method with a return type. A method without parameters but with a return type is a method that does not take any parameters but returns a value. This type of method is useful when we need to perform a specific task that does not require any input parameters, but we need to get a result from that task. First, let us get acquainted ... Read More

Advertisements