Blog

python tutorials and learn python

Created with Sketch.

Java for loop

  Java for loop Java for loop is used to repeat the execution of the statement(s) until a certain condition holds. for is a keyword in Java programming language. Java for loop syntax for (/* Initialization of variables */ ; /*Conditions to test*/ ; /* Increment(s) or decrement(s) of variables */) { // Statements to…
Read more

Java while loop

  Java while loop In Java, a while loop is used to execute statement(s) until a condition is true. In this tutorial, we learn to use it with examples. First of all, let’s discuss its syntax: while (condition(s)) { // Body of loop } 1. If the condition(s) holds, then the body of the loop…
Read more

Java program to print alphabets

  Java program to print alphabets Java program to print letters (i.e., a, b, c, …, z in lower case) on the screen using a loop. Java program class Alphabets { public static void main(String args[]) { char t; for (t = ‘a’; t <= ‘z’; t++) // For upper case use ‘A’ and ‘Z’…
Read more

Multiplication table in Java

  Multiplication table in Java Java program to print multiplication table of a number entered by a user using a for loop. You can modify it for while or do while loop for practice. Using nested loops (a loop inside another loop), we can print tables of numbers between a given range say a to…
Read more

How to take input from a user in Java

  How to take input from a user in Java Java program to get input from a user, we are using Scanner class for it. The program asks the user to enter an integer, a floating-point number, and a string, and we print them on the screen. Scanner class is present in “java.util” package, so…
Read more

Even odd program in Java

  Even odd program in Java Java program to check whether a number is even or odd; if it’s divisible by two, then it’s even, otherwise, odd. We use the modulus operator to find the remainder. For an even number, it’s zero when it’s divided by two (it’s one for an odd number). Odd even…
Read more

Java program to convert Fahrenheit to Celsius

  Java program to convert Fahrenheit to Celsius Java program to convert Fahrenheit to Celsius: This code does temperature conversion from the Fahrenheit scale to the Celsius scale. For Celsius to Fahrenheit conversion use: T = 9*T/5 + 32 ‘T’ is the temperature on the Celsius scale. Java temperature conversion program import java.util.*; class FahrenheitToCelsius…
Read more

Java methods

  Java methods Java methods tutorial: Java program consists of one or more classes, and a class may contain method(s). A class can do very little without methods. In this tutorial, we learn about Java methods (known as functions in C and C++ programming languages). A method has a name and return type. The main…
Read more

Static block in Java

  Static block in Java Java programming language offers a block known as static that runs before the execution of the main method. Below is an example to understand its functioning. Later, we see its practical use. Java static block program class StaticBlock { public static void main(String[] args) { System.out.println(“Main method is executed.”); }static…
Read more

Static method in Java with example

  Static method in Java with example Java static methods: we call them without creating an object of the class. Why is the main method static? Because program execution begins from it, and no object exists before calling it. Consider the example below: Static method Java program class Languages { public static void main(String[] args)…
Read more