Quantcast
Channel: Java - CoderzHeaven
Browsing all 14 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Simple String Concatenation Example in JAVA

Hi, Given below is a simple concatenation example in JAVA where two strings are joined together to form a single string. public class MainClass { public static void main(String[] arg) { String...

View Article



Image may be NSFW.
Clik here to view.

Exception Handling – Divide by Zero – Java Example

Hi, Given below is a code snippet which will demonstrate an exception handling in Java with Divide by zero error. public class MainClass { public static void main(String args[]) { int urAns, urDiv; try...

View Article

How to create a new file using JAVA ?

Hi, For creating a new file using JAVA, use the following code. import java.io.File; public class MainClass { public static void main(String[] a)throws Exception { File myFile = new...

View Article

How to find if a string starts with a particular word – JAVA ?

Hi, In order to find whether a given string starts with a particular string or not in JAVA, use the following code. public class Main { public static void main(String[] args) { String urStr = "Coderz...

View Article

Image may be NSFW.
Clik here to view.

How to Convert a string to date in JAVA ?

Hi, For converting string to a date in JAVA use the following code. import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] args) throws Exception...

View Article


Java check memory Allocation

class test { public static void main(String args[]) { Runtime r = Runtime.getRuntime(); long mem1, mem2; Integer someints[] = new Integer[1000]; System.out.println("Total memory is: "...

View Article

JComboBox in Java swing

This shows you how to add JcomboBox to JPanel import java.awt.*; import java.awt.event.*; import java.text.DecimalFormat; import javax.imageio.ImageIO; import javax.swing.*; public class Example...

View Article

Java Applet MouseEvents

A simple event based applet applications is described below First importing the necessary header files // Demonstrate the mouse event handlers. import java.awt.*; import java.awt.event.*; import...

View Article


Creating a JButton component in swing

Java swing provides a native look and feel that emulates the look and feel of several platforms. Here i am going to create a Button and adding it to Frame. For this first create a Jframe object,a...

View Article


Image may be NSFW.
Clik here to view.

How to find your Google Plus ID

This is so simple 1. Go to your Google + account (https://plus.google.com/). 2. Click on the Profile icon on the Left. 3. If you look at the URL in the address bar, it should look something like this:...

View Article

What are static variables? Why it is used? What is it’s use? – A Common...

The static keyword is used in java mainly for memory management. We may apply static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of...

View Article

Reverse a byte array in Android

Here is a simple function to reverse a byte array in android. public static void reverse(byte[] array) { if (null == array) { return; } int i = 0; int j = array.length - 1; byte tmp; while (j > i) {...

View Article

Given a sorted array, find the smallest positive integer that is not the sum...

Java public class SmallestPositiveInteger {    public static int findSmallestPositiveInteger(int[] nums) {        int smallest = 1;        for (int num : nums) {            if (num <= smallest) {...

View Article


Problem: There are N prisoners standing in a circle, waiting to be executed…

There are N prisoners standing in a circle, waiting to be executed. The executions are carried out starting with the kth person, and removing every successive kth person going clockwise until there is...

View Article
Browsing all 14 articles
Browse latest View live




Latest Images