• 20 January

    Java program to count number of words in sentence

    In this tutorial, we will see a simple java program to count number of words in sentence. [crayon-662b95a9c6bdf410345346/] Output: Enter a Sentence : Java2Blog is a technical blog. Total number of words are 5 That’s all about Java program to count number of words in sentence.

  • 20 January

    Java program to find largest number in array

    In this tutorial, Java program to find the largest number in array. Here is simple algorithm to find larget element in the array. Initialize lrg with arr[0] i.e. first element in the array. If current element is greater than lrg, then set lrg to current element. [crayon-662b95a9c7728356569820/] Output: Enter Array Size : 5 Enter Array […]

  • 20 January

    Java program to find minimum value in array

    In this tutorial, Java program to find minimum value in an array. Here is simple algorithm to find minimum value in the array. Initialize sml with arr[0] i.e. first element in the array. If current element is less than sml, then set sml to current element. [crayon-662b95a9c89fe878160508/] Output: Enter array Size : 3 Enter array […]

  • 20 January

    Java program to print Diamond pattern

    In this tutorial, we will see java program to print diamond pattern. [crayon-662b95a9c9167713688180/] That’s all about printing diamond pattern in java.

  • 20 January

    Java program to print Fibonacci Series

    In this tutorial, we will print fibonacci series. According to wikipedia: In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:[1][2] 0,1,1,2,3,5,8,13,21,34,55,89,144.. Here is simple program to print […]

  • 19 January

    How to Compare Two Strings in Java

    In this post, we will see how to compare two String in java. As you might know, String implements Comparable interface, you can use compareTo method to compare two String in java. [crayon-662b95a9cad86755323670/] Output: Enter First String : Java Enter Second String : Blog First String is Greater than Second String. That’s all about How […]

  • 19 January

    Java program for sum of digits of number

    In this post, we will see how to find sum of digits of number in java. You can find unit’s place digit by number%10, add it to the total and divide the number by 10 to remove the unit’s place. [crayon-662b95a9cb66e384657157/] Output: Enter a Number : 5385 Sum of digits of number 5385 is 21 […]

  • 19 January

    Java program to calculate average marks

    In this post, we will see simple java program to find average and percentage marks. We have taken average and percentage of five subject marks below. [crayon-662b95a9cbe7a439751699/] Output: Enter marks for 5 Subjects : 91 57 83 69 74 Average Marks = 74.8 Percentage = 74.8% That’s all about Java program to calculate average and […]

  • 19 January

    Java program to make simple calculator

    In this post, we will see how to create a simple calculator in java. This calculator program performs 4 basic operatios – Addition, Substraction, Multiplication and division.It uses Switch case to choose operation you want to perform. [crayon-662b95a9cc8c5116468908/] Output: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. ExitEnter your operation : 3 Enter Two […]