About 1,030,000 results
Open links in new tab
  1. Java Program to Find Square of a Number - Tutorial Gateway

    Write a Java Program to find Square of a Number using methods with example. Java Program to Find Square of a Number Example 1. This Java program allows the user to enter an integer value. Then this Java program calculates the square of that number using Arithmetic Operator.

  2. java - Method to return square of a number - Stack Overflow

    Dec 1, 2013 · There isn't a print statement in Java - you need to use the method System.out.println(square(num)); Although, actually, your square method is writing the squared number to STDOUT anyway, so you don't need to do any more printing - …

  3. How to Square a Number in Java? - JavaBeat

    Dec 30, 2023 · Three different methods in Java are used for taking a square. These methods include multiplying the number with itself, by using the functions, or by using the BigInteger class. One of the simplest approaches is to multiply the number by itself using the asterisk (*).

  4. How to Square a Number in Java: A Step-by-Step Guide - Code …

    Feb 11, 2024 · This Java program is designed to demonstrate how to square a number using a simple, clean method. The architecture of the code includes two main sections: the main method, which serves as the entry point of the program, and a separate square method, that handles the actual squaring logic.

  5. java.util.scanner - Java, square a number - Stack Overflow

    I am working on a basic assignment for school, namely to square a number. And, I have written the following code; Scanner scan = new Scanner(System.in); System.out.print("Write a number: "); String mataintal = scan.next(); int nr = Integer.parseInt(mataintal); String.out.println = …

  6. How to Square a Number in Java? - Techgeekbuzz

    Feb 11, 2025 · There are many ways to square a number in Java, the simplest of which is multiplying the number by itself. There are also utility methods to do the same. If your project needs to do this often, you can build a function and call the utility as well.

  7. Java: How to square a number - alvinalexander.com

    Jul 30, 2024 · Solution 1) Java: Square a number by multiplying it by itself; Solution 2) Java: Square a number with the Math.pow method; More Java power multipliers

  8. Java - How to find Square of a Number - Techndeck

    Jul 22, 2020 · java.lang.math class provides a method Math.pow () to get the square of a number. Like below: Square = Math.pow (number,2); Note: number is the first argument for which we want to create the square. the second argument is the power by which you are raising the number. To get the square, you need ‘2’ as the second argument. Example: Output: Note:

  9. Java program to find square of a number - tutorialsinhand

    Lets learn to write a java program to find square of a number provided by user. Lets see the process of finding square of number. Suppose, number = 5, its square is 5*5 = 25. number = 7, its square is 7*7 = 49. number = 25, its square is 25*25 = 625. Basically, square of a number is number multiplied by itself as shown above.

  10. Java program for calculating square of a number - Students …

    Java program for calculating square using method. import java.util.Scanner; public class SquareNum { public static void main(String [] args) { Scanner sc = new Scanner(System.in); System.out.print("Please enter a number: "); int num = sc.nextInt(); System.out.println("Your squared number is: " + square(num)); } public static int square(int num ...

  11. Some results have been removed
Refresh