
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 33676 Articles for Programming

753 Views
In this tutorial, we are going to see how to sort a list of strings. We'll sort the given list of strings with sort method and sorted function. And then we'll see how to sort the list of strings based on different criteria like length, value, etc., Let's see how to sort a list of strings using list.sort() method. The sort method list is an insort. It'll directly sort the original list. Let's see the code.Example Live Demo# list of strings strings = ['Python', 'C', 'Java', 'Javascript', 'React', 'Django', 'Spring'] # sorting the list in ascending order strings.sort() # printing the ... Read More

2K+ Views
In this tutorial, we are going to learn about the holidays library. The holidays library will help to determine whether a particular is a holiday or not in different countries. We can only see the public holidays.Let's install the module with the following command.pip install holidaysAfter successfully installing the module follow the ways to see get the holidays information. see the holidays of India in the year 2020. You have to follow the below steps to get a complete list of holidays for India in 2020.You can find the country codes for the holidays here..Import the holidays' module.Instantiate the holidays.India() ... Read More

3K+ Views
In this tutorial, we are going to write a program that groups similar substrings from a list. Let's see an example to understand it more clearly.Inputstrings = ['tutorials-python', 'tutorials-c', 'tutorials-java', 'tutorials-javascript', 'python-1', 'python-2', 'javascript-1']Output[['tutorials-python', 'tutorials-c', 'tutorials-java', 'tutorials-javascript'], ['python-1', 'python-2'], ['javascript-1']]We are going to use the groupby method from itertools module to solve the problem. The groupby method will group all the similar string into an iter object. For the given list we have split the string with - and pass the first part of the string to the groupby method.Let's see the steps involved in solving this problem.Initialize the list ... Read More

830 Views
To split the Even and Odd elements into two different lists, the Java code is as follows −Example Live Demoimport java.util.Scanner; public class Demo{ public static void main(String[] args){ int n, j = 0, k = 0; Scanner s = new Scanner(System.in); System.out.println("Enter the number of elements required :"); n = s.nextInt(); int my_arr[] = new int[n]; int odd_vals[] = new int[n]; int even_vals[] = new int[n]; System.out.println("Enter the elements of the array(even and add numbers) ... Read More

2K+ Views
In this article, we will learn to find missing and additional values in two lists in Java. By the end of this program, you'll be able to detect elements that exist in one list but not in the other, helping you better manage and analyze data in list comparisons. Problem Statement Write a program in Java to find missing and additional values in two lists. Below is the demostration − Input 101, 90, 34, 34, 67, 90 Output The missing element is : 101The new element in the list is : 67 Steps to find missing and additional values in two ... Read More

399 Views
To generate random numbers in a given range, the Java code is as follows −Example Live Demoimport java.util.Random; import java.util.*; public class Demo{ public static void main(String args[]){ Random my_rand = new Random(); List my_list_1 = new ArrayList(); int v_1 = my_rand.nextInt(1000); int v_2 = my_rand.nextInt(967); int v_3 = my_rand.nextInt(1050); int v_4 = my_rand.nextInt(10000); int v_5 = my_rand.nextInt(100); my_list_1.add(v_1); my_list_1.add(v_2); my_list_1.add(v_3); my_list_1.add(v_4); my_list_1.add(v_5); ... Read More

5K+ Views
Splitting and join a string To split and join a string in Java, use the split() and join() method as in the below example − Example A class named 'Demo' contains the main function. Here a String object is defined and split based on the '_' value up to the last word. A 'for' loop is iterated over, and the string is split based on the '_' value. Again, the string is joined using the 'join' function, and the output is displayed. public class Demo{ public static void main(String args[]){ String ... Read More

1K+ Views
Let’s say we have an Octal number. To convert Octal to other bases like binary, hexadecimal, etc, the Java code is as follows −Example Live Demopublic class Demo{ public static String base_convert(String num, int source, int destination){ return Integer.toString(Integer.parseInt(num, source), destination); } public static void main(String[] args){ String my_num = "345"; int source = 8; int destination = 2; System.out.println("Converting the number from octal to binary: "+ base_convert (my_num, source, destination)); destination = 10; System.out.println("Converting the number ... Read More

3K+ Views
Let us see how to write an empty function in Java −Example Live Demoimport java.util.Vector; public class Demo{ public static void my_empty_fun(){ } public static void main(String[] args){ System.out.println("In the main function"); my_empty_fun(); } }OutputIn the main functionAn empty function is basically creating a function without defining any operations inside it. A class named Demo contains an empty function named ‘my_empty_fun’ which is just completed by placing two flower brackets, without adding any functionality into it. In the main function, a print statement is written after which the empty function ... Read More

994 Views
Eeverytime a process or a code or a thread needs to run in Java, a runtime stack is created so as to store the operations performed while executing the thread.Every entry in the run-time stack is known as stack frame or activation record. Once a function has been called by the process, its associated data is deleted from the runtime stack.Once all the functions have been called, the runtime stack will be empty. This means it needs to be removed from the memory.At this point in time, the runtime stack is destroyed and then the thread is also terminated.A termination ... Read More