MySQL – Quick Introduction

Installing MySQL on Linux (Ubuntu) Open Terminal and run following set of commands. [Please Note:  Installation requires you to have administrator password on Ubuntu] sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install libmysql-java During installation MySQL wizard may give a pop-up to provide password for root – Specify it as root. [Administrator…

Multithreading Tabbed Browser

Multi-threading Tabbed Browser import java.util.Random; class BrowserTabHandler extends Thread { String url; int delayTimeInSeconds; int tabId; public BrowserTabHandler(String url, int tabId) { this.url = url; this.tabId = tabId; Random r = new Random(); delayTimeInSeconds = r.nextInt(10); System.out.printf(“[TAB: #%d] – URL: %s: Random Delay In Seconds: %d\n”, tabId, url, delayTimeInSeconds); } public void run() { try{…

Multithreading solution

Multi-threading solution – Runnable interface method class DownloadManager implements Runnable { static final int WAIT_TIME_MILLISECONDS = 500; static final int TOTAL_ITERATIONS = 60; public void run() { downloadFile(); } public void downloadFile() { int i; for(i=0;i<TOTAL_ITERATIONS;i++) { System.out.println(“Download File “+i); try { Thread.sleep(WAIT_TIME_MILLISECONDS); } catch(Exception e) { System.out.println(“Exception in Downloading File”); } } } }…

Multithreading exercise

Multi-threading exercise In our day to day use of our PC/laptops, we do multiple things in parallel like surfing internet ( or sometimes practicing Java coding) while listening to music. In this exercise, we are trying to do two things –    1. download a file and    2. listen to a song. Class DownloadManager is providing…

Java – Multithreading

We can think thread as a component of processes. Every process has at least one thread. Multiple threads can exist within the same process, executing concurrently and sharing the process’s resources, including memory and open files.   Q for thought: why do we need multi-threading ? Can you think of some scenarios where multi-threading helps /is required…

Java – String Class

String – Class or Primitive Data Type? String is a most frequently used Java class. Ideally to create object of String class we should write code like String s = new String(“Being Zero”); But since it is most frequently used class, Java has made it easy for us to create string objects by directly assigning it…

Java – Class

Class is referred to a User Defined Data Type.  Generally in real world it represents a category of things,  Object is a uniquely identifiable entity of Data Type Class. MobilePhone is a class, as it represents category of devices. My iPhone 6S with IMEI Number XXXXXX and a Wallpaper of Company Logo – is uniquely…

Java – Objects

Objects are similar to variables. With few differences that will become evident in next few lines of the tutorial. Java has Eight Primitive (Basic) Data Types and Huge number of Classes (Complex Data Types). Declaration Syntax There is no difference between way we declare a variable and the way we declare an object. int a; //…

Java – Variables

Variables are essential part of a Java program.  Imagine if we were to write a program that prints maximum value of of three given values;  Where we store these three values and how do we compare them? That’s where variables fit it. Their key use is to hold a value. Now each variable that we…