- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2616 Articles for Java
![Neetika Khandelwal](https://www.tutorialspoint.com/assets/profiles/507566/profile/60_4169811-1661487212.jpg)
62 Views
The goal is to determine the minimum time required to complete the tasks in queue A based on the order of execution in queue B, given two queues A and B, each of size N, where: Pop this task and run it if the task identified at the head of queue B is also at the head of queue A. Pop the current task from queue A and push it at the end if the task discovered at the front of queue B is not also found at the front of queue A. One unit of time is ... Read More
![Neetika Khandelwal](https://www.tutorialspoint.com/assets/profiles/507566/profile/60_4169811-1661487212.jpg)
43 Views
Given are N processes and two N−sized arrays, arr1[] and arr2[]. A process's time in the critical section is recorded in arr1[], and it’s time to finish processing after leaving the critical part is recorded in arr2. The goal is to determine how long it will take for each process to finish processing (both inside and outside of the critical section) in any given order. Input Output Scenarios Assume we have 3 arrays as shown below Input N = 3, arr1[] = {1, 4, 3}, arr2[] = {2, 3, 1} Output 9 The first process, at ... Read More
![Neetika Khandelwal](https://www.tutorialspoint.com/assets/profiles/507566/profile/60_4169811-1661487212.jpg)
275 Views
In this article, you will learn about how to find the order of execution for the given N processes in the Round Robin Scheduling algorithm. But before starting with the code, let’s understand a bit about how this algorithm works. Round Robin Scheduling is a popular CPU scheduling algorithm used in operating systems to allocate CPU time to multiple processes in a fair and efficient manner. In this blog, we will explore how round−robin scheduling works, its advantages and disadvantages, and provide an example to help you understand the concept better. What is Round Robin Scheduling? Round Robin Scheduling is ... Read More
![Vanshika Sood](https://www.tutorialspoint.com/assets/profiles/641407/profile/60_757993-1681820687.jpeg)
265 Views
This article seeks a method for setting a given number's leftmost unset bit. The first unset bit after the most significant set bit is considered the leftmost unset bit. Problem Statement Given a number n, the task is to set the left most bit of the binary expansion of the number that is unset. All the other bits should be left unchanged. If all the bits of the original number are already set, return the number. Examples Input: 46 Output: 62 Explanation Binary Expansion of 46 = 101110. Left most unset bit is 101110. Upon setting the underlined ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
136 Views
In this problem, we need to find the length of the longest subsequence having the same left and right rotations. We can solve the problem using the brute-force approach, finding all possible subsequences of the given string and checking each subsequence one by one to see if it has the same left and right rotation. We find the maximum length of such subsequence. The problem with this approach is that it is very time-consuming as its time complexity is O(2N). So, we will learn to write optimized code in this approach. Problem statement – We have given string str containing ... Read More
![Mr. Satyabrata](https://www.tutorialspoint.com/assets/profiles/526132/profile/60_3653035-1664258182.jpeg)
900 Views
A prime number is a positive integer greater than 1 that is only divisible by 1 and itself. Prime numbers are an essential concept in mathematics and computer science. They are integers that are only divisible by 1 and themselves. Finding prime numbers is an important task in many algorithms, and there are several methods to determine if a number is prime. One such problem is finding the closest prime number to a given number. Problem Statement For a given number find the closest prime number by using Java programming language. Consider the following example - Input ... Read More
![Mr. Satyabrata](https://www.tutorialspoint.com/assets/profiles/526132/profile/60_3653035-1664258182.jpeg)
2K+ Views
In Java, an ArrayList is a resizable array, which is implemented as part of the Java Collections Framework. It is a dynamic data structure that can hold any type of objects, including primitive types such as integers and characters. As per the problem statement we have to read a file into an ArrayList. First and foremost we will take the path of the file as input and then we will apply different method to read the file. Let's start! For instance Suppose the input file is “myfile.txt”. After reading the content of the file, the result ... Read More
![Mr. Satyabrata](https://www.tutorialspoint.com/assets/profiles/526132/profile/60_3653035-1664258182.jpeg)
8K+ Views
In Java, Timestamp can be converted Date by using Date class. Date class is present in java.util package. The constructor of the Date class receives a long value as an argument. Since the constructor of the Date class requires a long value, we need to convert the Timestamp object into a long value using the getTime() method of the TimeStamp class. Let's deep dive into this article, to know how it can be done by using Java programming language. To show you with instance Suppose the timestamp is 06/01/2023. Then corresponding Date is “Fri Jan ... Read More
![Mr. Satyabrata](https://www.tutorialspoint.com/assets/profiles/526132/profile/60_3653035-1664258182.jpeg)
523 Views
In Java, smaller datatype can be converted to bigger datatype. Here, we will see how to convert char datatype to int datatype. The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65, 535 inclusive). The int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. Let's deep dive into this article, to know how it can be done by using Java programming language. For instance Suppose the given ... Read More
![Mr. Satyabrata](https://www.tutorialspoint.com/assets/profiles/526132/profile/60_3653035-1664258182.jpeg)
201 Views
In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill Primary Diagonal with 1 and Secondary Diagonal with 0. Let's start! For instance Suppose we have 4*4 matrix i.e. 4 rows and 4 columns. After performing the operation on matrix, the result will be: Enter the size of the matrix: ... Read More