public static boolean isConsecutive(Stack<Integer> s) { Queue<Integer> q = new LinkedList<Integer>(); if (s.size() < 2) { return false; } while (!s.isEmpty()) { q.add(s.pop()); } boolean consecutive = true; s.push(q.remove()); while (!q.isEmpty()) { if (s.peek() – 1 != q.peek()) { consecutive = false; } s.push(q.remove()); } while (!s.isEmpty()) { q.add(s.pop()); } while (!q.isEmpty()) { s.push(q.remove()); }… Continue reading linkws


import java.util.*; public class LinkedListDemo { public static void main(String args[]) { // create a linked list LinkedList ll = new LinkedList(); // add elements to the linked list ll.add(“F”); ll.add(“B”); ll.add(“D”); ll.add(“E”); ll.add(“C”); ll.addLast(“Z”); ll.addFirst(“A”); ll.add(1, “A2”); System.out.println(“Original contents of ll: ” + ll); // remove elements from the linked list ll.remove(“F”); ll.remove(2); System.out.println(“Contents… Continue reading kk


// Java program implementing Singleton class // with getInstance() method class Singleton { // static variable single_instance of type Singleton private static Singleton single_instance = null; // variable of type String public String s; // private constructor restricted to this class itself private Singleton() { s = “Hello I am a string part of Singleton… Continue reading singleton

class input

class Std {    private static int year = 2018;    private String name;    private int age;    public Std(String name, int age){ = name;       this.age = age;    }    public void setName(String name) { = name;    }    public void… Continue reading class input

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!