replace

Replace all occurrences of a character in String

Replace all occurrences of a character in String Method 1: import java.util.Arrays; class Replaceall { public void replaceAll(String t ) { StringBuilder sb = new StringBuilder(); for(int i = 0; i < t.length(); i++) { if(t.charAt(i) == ‘s’) sb.append(‘R’); else sb.append(t.charAt(i)); } System.out.println(sb); } public

spiralmatrix

Adding numbers into spiral matrix

Adding numbers into spiral matrix public class MatrixCount { int[][] array1 = new int[4][4]; public void draw() { int i =0, j= -1, count = 1; while(array1[i][j+1] == 0) { while( j < 3 && array1[i][j+1] == 0 ) { j = j+ 1; array1[i][j]

spaceshooter

SpaceShooter : Unity 3D game

Though no one seems to be interested in Arcade style shooting games these days when we have Giant games which simulate real world pretty well, but I am sure 90’s kids will be up for this Anyway, again it being a part of my learning

MadDash_Title

MadDash

Let me start by saying it’s a pretty simple and naive game. Conceptually, all that one needs to do is collect power ups before the time runs out and Time goes up with Power Ups.Race against time. Pretty common, huh? Yet it was fun. Trust

sorted Array Via Linked List

Sorting elements of an array via Sorted List

Sorting elements of an array via Sorted List class Link { Link next; int value; Link(int val) { value = val; } } public class SortedArrayviaSortedList { static int arr[]; int i; Link pPrevious = null; Link pfirst; Link pCurrent = pfirst; SortedArrayviaSortedList(int arr[]) {

sorted Linked List in Java

Sorted Linked List in Java

Implementing sorted Linked List in Java class Link { public int data; public Link next; Link(int value) { data = value; } } public class SortedLinkedList { Link pfirst; Link pCurrent; Link pPrevious; public void SortedInsert(int value) { Link newLink = new Link(value); pCurrent =

queue in Java using LinkedList

Queue in Java using LinkedList

Implementing Queue in Java using LinkedList class Link { Link next; int value; Link(int val) { value = val; } } public class QueueLinkedList { Link pfirst; Link pLast; public void enqueue(int value) { Link newLink = new Link(value); if(isEmpty()) pfirst = newLink; else pLast.next

doubly list in java

Double ended List in Java

Double ended List in Java class Link { int val; Link next; Link(int value) { val = value; } public String toString() { return “{” + val + “}” ; } } public class DoublyList { Link pfirst = null; Link pLast= null; public void

print numbers without using loops

Java program to print counting without using loop

Print counting till n (40 in this case) without using loop Solution : Recursion public class PrintTillHundred { public static void main(String…s) { recurse(1); } public static void recurse(int i) { if(i>40) { System.out.println(“Number greater than 40, Program ending……….. “); return; } else { System.out.println(i);