Mohammad Towhidul Islam

    17-Apr-14 05:31:00 pm

    Enhanced for loop java example

    Enhanced for loop java: Enhanced for loop is useful when scanning the array instead of using for loop. Syntax of enhanced for loop is: for (data_type variable: array_name) Here array_name is the name of array. Code class EnhancedForLoop { public static void main(String[] args) { in...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 05:26:05 pm

    Java program example to transpose matrix

    Code import java.util.Scanner; class TransposeAMatrix { public static void main(String args[]) { int m, n, c, d; Scanner in = new Scanner(System.in); System.out.println("Enter the number of rows and columns of matrix"); m = in.nextInt(); n = i...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 05:23:15 pm

    Java program example to multiply two matrices

    Code import java.util.Scanner; class MatrixMultiplication { public static void main(String args[]) { int m, n, p, q, sum = 0, c, d, k; Scanner in = new Scanner(System.in); System.out.println("Enter the number of rows and columns of first matrix"); m...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 05:19:27 pm

    Java program example to add two matrices

    This java program add two matrices. You can add matrices of any order. Code import java.util.Scanner; class AddTwoMatrix { public static void main(String args[]) { int m, n, c, d; Scanner in = new Scanner(System.in); System.out.println("Enter the number of row...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 05:13:03 pm

    Java program to get ip address

    This program prints IP or internet protocol address of your computer system. InetAddress class of java.net package is used, getLocalHost method returns InetAddress object which represents local host. Code import java.net.InetAddress; class IPAddress { public static void main(String args[...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 05:09:37 pm

    Java program example static block

    Java programming language offers a block known as static which is executed before main method executes. Below is the simplest example to understand functioning of static block later we see a practical use of static block. Code class StaticBlock { public static void main(String[] args) { ...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 04:57:30 pm

    Java program example to bubble sort

    Complexity of bubble sort is O(n2) which makes it a less frequent option for arranging in sorted order when quantity of numbers is high. Code import java.util.Scanner; class BubbleSort { public static void main(String []args) { int n, c, d, swap; Scanner in = new Scanner(System.in...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 04:52:42 pm

    Java program example for binary search

    Java program for binary search: This code implements binary search algorithm. Please note input numbers must be in ascending order. Code import java.util.Scanner; class BinarySearch { public static void main(String args[]) { int c, first, last, middle, n, search, array[]; Sca...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 04:47:27 pm

    Java program example to print prime numbers

    We have used sqrt method of Math package which find square root of a number. To check if an integer(say n) is prime you can check if it is divisible by any integer from 2 to (n-1) or check from 2 to sqrt(n), first one is less efficient and will take more time. This java program prints prime number...

    Read More


    Mohammad Towhidul Islam

    17-Apr-14 04:39:16 pm

    Java program example to check palindrome

    Java program to check if a string is a palindrome or not. Remember a string is a palindrome if it remains unchanged when reversed, for example "dad" is a palindrome as reverse of "dad" is "dad" whereas "program" is not a palindrome. Code import java.uti...

    Read More


First1234Last
2 of 4 pages
Copyright © 2025. Powered by Intellect Software Ltd