EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Java practice programs in data structures

Given a non-empty array of integers nums[], every element appears twice except for one. Find that single one.   Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4     ——————————— public class Main { public static int SingleNumber(int[] nums)//2,2,1 { int result = 0; for (int num : nums) […]

Java practice programs for leetcode

Create an interface Printable with a method print(), implement this interface in classes Document and photo   interface Printable { void print(); }   class Document implements Printable { void print() { System.out.println(“Document printed”); } }   class Photo implements Printable { void print() { System.out.println(“Photo printed”); } }   class Main { public static […]

Java code to create rectangle with attributes

Create a class Rectangle with attributes length and width. Use a constructor to initialize values and calculate the area   class Rectangle { int length, width;   Rectangle(int l,int w) { length=l; width=w; }   int area() { return length*width; } } class Main { public static void main(String args[]) { Rectangle r=new Rectangle(10,2); System.out.println(“Area=” […]

Java practice programs to create student details form

Create a student class with name, roll number. Use a constructor to initialize and display the student details     class Student { String name; int rollNo;   Student(String name,int rollNo) { this.name=name; this.rollNo=rollNo; }   void display() { System.out.println(name); System.out.println(rollNo); } } class Main { public static void main(String args[]) { Student s1=new Student(“John”,101); […]

Java data structures practice programs

  Traversing in binary tree   int countLeafNodes(Node root) { if(root==null) return 0;   Stack<Node> stack=new Stack<>(); stack.push(root); int leafcount=0;   while(!stack.isEmpty()) { Node current=stack.pop();   if(current.left==null && current.right==null) leafcount++; if(current.right!=null) stack.push(current.right); if(current.left!=null) stack.push(current.right); } return leafcount; }

java data structures node insertion simple program

Insert the node at middle(value,position)   public void insertAtposition(int pos, int val)//pos=2, val=52 { Node newNode=new Node(val);   Node temp=head;   for(int i=1; i<pos; i++)i=2;2<2 { temp =temp.next; } newNode.next=temp.next; temp.next=newNode; }

Linear data structure in java

import java.util.*; class Stacksearch { public static void main(String args[]) { Stack<String> s=new Stack<>();   //push the elements(inserting elements)   s.push(“Apple”); s.push(“Banana”); s.push(“cherry”);   System.out.println(“the elements are: +s);   String searchelement=”cherry”;   int position=s.search(searchelement);   if(position != -1) { System.out.println(searchelement +”found at the position(from top)” +position); } else { System.out.println(searchelement +”not found inside the stack”); […]

Java stack in data structures

Stack:   A stack is a linear data structure that follows LIFO(LAST IN FIRST OUT) principle   linear data structure–>where elements are arranged in a sequence order. Every elements will be connected to its previous or next element   Task Description   push(item)———————-Adds an item to the top of the stack   pop()—————————Remove and return […]

Java example programs for practice

A company is validating usernames for its internal employee portal   Every employee enters their full name as a string like “john_123”   your job is to write a program that does the following:   1. Accept a string that represents a username   2. Check if the username (i) contains only lowercase letters, digits […]

Java example programs for practicing

Missing Attendance roll number: Given roll numbers from 1 to N,one is missing. Find the missing number   int rolls[]={1,2,3,5}   output: Missing number=4   —————————————————————————— 2)Find Duplicate ID: In an employee array, one ID is duplicated. Find that duplicate   int empIDs={101, 103, 104, 101, 105}   output: Duplicate: 101   class DuplicateID { […]

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer