Category Java

Depth-first search algorithm

Depth-first search algorithm

Depth-first search (DFS) is a search algorithm that explores the search tree by going as deep as possible along each branch before backtracking. This means that it explores each branch of the search tree as far as possible before moving…

Breadth-first search algorithm

breadth-first search

The breadth-first search (BFS) algorithm is a search algorithm that explores the search tree by visiting all of the nodes at the same depth before moving on to the next level. This means that it visits all of the nodes…

Setup JAVA_HOME on Apple Mac

Setup Java_Home

Download the latest java from Oracle Open terminal and check the java version 2. Check if JAVA_HOME is set echo $JAVA_HOME 3. If it returned empty then on the home / check for the file ~/.zshenv by hitting ls…

JAVA J2EE Technical Architect Profile

 JAVA J2EE Technical Architect Profile Java Tech Arch Profile Image credit: Freepic.com Position Responsibilities: Identify target application architecture. Direct proof-of-concept initiatives. Analyze feasibility by presenting proof-of-concepts (POCs). Design the technical solution, including the infrastructure design. Define the product definition, cost…

Different types of pointers

Void pointer (generic pointer) : a special type of pointer which point to some dataof no specific types.void *p; Null pointer : a special type of pointer which point nowhere.it is usually used to check if a pointer is pointing to a…

Write a java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green. When a radio button is selected, the light is turned on, and only one light can be on at a time No light is on when the program starts.

//Program for implementing Traffic Signals import java.applet.*; import java.awt.*; import java.awt.event.*; /*<applet code=”Signals” width=400 height=250></applet>*/ public class Signals extends Applet implements ItemListener {             String msg=””;             Checkbox  stop,ready,go;             CheckboxGroup cbg;             public void init()             {                         cbg…

Write a Java program that correctly implements producer consumer problem using the concept of multithreading.

Java Design Patterns | Consumer and Producer Pic credit: Freepic.com // implementation of a producer and consumer. class Q {             int n;             boolean valueSet = false;             synchronized int get()              {                         while(!valueSet)                         try                         {…

Create a user defined exception in java

Java Custom Exceptions Program to create a user defined exception class Myexception extends Exception {             int detail;             Myexception(int a)             {                         detail=a;             }             public String toString()             {                         return “Myexception[“+detail+”]”;             } } class…

Enable Notifications OK No thanks