Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: Modulus Operator Example

public class Modulo {
  public static void main(String[] args) {
    int i = 100;
    double d = 2;
    System.out.println("i mod 10 = " + i % 6);

Java: How to convert a string to an int

public class StringToInt 
{
  public static void main(String[] args) 
 {
    String unString = "152";
    int unInt = Integer.parseInt(unString);

Java: Do While Statements Example

public class DoWhileDemo
 {
  public static void main(String[] args) {
    String srcText = "Copy this string until you encounter the letter 'v'.";

Java: How to Use foreach style for loop.

public class ForEach
 {
  public static void main(String args[]) 
{
    int values[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    int sum = 0;
    f

Java: Demonstrates the while loop.

public class WhileTest 
{
  public static void main(String[] args) 
 {
    double r = 0;
    while(r < 0.99d) 
    {
      r = Math.random();
      S

Java: Do While Statements Example

public class DoWhileDemo
 {
  public static void main(String[] args) {
    String srcText = "Copy this string until you encounter the letter 'v'.";

Java: How to use if Else statements

public class IfElseDemo {
    public static void main(String[] args) {
        double note = 69;
        String mention="";
        if (note >=

Java: Using a foreach loop with a collection.

import java.util.ArrayList;
public class ForEachAndCollection 
{
   // Find the average of the array
  static double getAvg(ArrayList nums) 
{

Java: How to Use scanner to compute an average of csv file.

import java.util.*;
import java.io.*;
public class ScannerwithCSV
 {
  public static void main(String args[])
    throws IOException {
    int counte

Java: How to use ‘instanceof’ keyword to find the class of an object

import java.util.ArrayList;
import java.util.Vector;
public class FindInstance 
{
  public static void main(String[] args)
 {
    Object testObj

Java: List ASCII Codes and ASCI Characteres

public class TableAscii {
  public static void main(String[] args) 
{
    char lettreHex;
    char codeAsc = 0x20;
     // Counters for rows and c

Java: How to use multiple expressions in for loops

public class ForLoopExample 
{
  public static void main(String[] args) 
   {
    for (int i = 0, j = 0; i < 5; i++, j--)
      System.out.println

Java: How to use foreach with generic data structure

import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
public class ForeachDemo 
  {
  static void iterate(Collection c

Java: Searches the array for a given value using foreach loop.

public class ForEachAndSearch 
{
  public static void main(String args[]) 
{
    int nums[] = { 6, 8, 3, 7, 5, 6, 1, 4 };
    int val = 5;
    b

Java: How to use foreach loop on a two-dimensional array.

public class ArrayAndForEach 
{
// Calculate the sum of a two-dimensional array
  public static void main(String args[]) 
{
    int sum = 0;