Mindblown: a blog about philosophy.

  • Program to get IP address

    In this example we are gonna see how to get IP address of a System. The steps are as follows: 1) Get the local host address by calling getLocalHost() method of InetAddress class.2) Get the IP address by calling getHostAddress() method. Output:

  • Program to read integer value from the Standard Input

    Example: Program to read the number entered by user We have imported the package java.util.Scanner to use the Scanner. In order to read the input provided by user, we first create the object of Scanner by passing System.in as parameter. Then we are using nextInt() method of Scanner class to read the integer. If you are new to Java…

  • Java program to check prime number

    The number which is only divisible by itself and 1 is known as prime number, for example 7 is a prime number because it is only divisible by itself and 1.This program takes the number (entered by user) and then checks whether the input number is prime or not. The program then displays the result. If…

  • Program to display first 100 prime numbers

    Program to display first n prime numbers Output: Program to display first 100 prime numbersTo display the first 100 prime numbers, you can either enter n value as 100 in the above program OR write a program like this: Output:

  • Program to Reverse a String using Recursion

    Example 1: Program to reverse a string Output: Example 2: Program to reverse a string entered by user Output:

  • Program to check palindrome string using recursion

    Program: Check whether String is palindrome using recursion Output: Output 2:

  • Program to reverse a number using for, while and recursion

    Program 1: Reverse a number using while Loop In this program, we are taking the input number from the user using Scanner class and then we are reversing the number using while loop. The logic we are using here is: Inside the while loop we are dividing the given number by 10 using % operator and then storing the remainder in the reversenum variable after…

  • Program to Sort an Array in Ascending Order

    Program to Sort an Array in Ascending Order In this program, user is asked to enter the number of elements that he wish to enter. Based on the input we have declared an int array and then we are accepting all the numbers input by user and storing them in the array. Once we have all the…

  • Program to sum the elements of an array

    n this tutorial we will see how to sum up all the elements of an array. Program 1: No user interaction Output: Program 2: User enters the array’s elements Output:

  • Program to reverse the Array

    Program to reverse the array Output:

Got any book recommendations?