To do this with user input:
public static void getPow(){ Scanner sc = new Scanner(System.in); System.out.println("Enter first integer: "); // 3 int first = sc.nextInt(); System.out.println("Enter second integer: "); // 2 int second = sc.nextInt(); System.out.println(first + " to the power of " + second + " is " + (int) Math.pow(first, second)); // outputs 9
Related Posts:
- Does Java have an exponential operator?
- Problem with gif with transparent background
- Search for words with telephone numbers from 2-3-4 tree
- How to use Collections.sort() in Java?
- Java 8 Iterable.forEach() vs foreach loop
- How to round a number to n decimal places in Java
- Error unable to access jarfile C:\Jar
- In laymans terms, what does ‘static’ mean in Java? [duplicate]
- What does “|=” mean? (pipe equal operator)
- What is the difference between a static method and a non-static method?
- Is there a method that calculates a factorial in Java?
- What is Java Servlet?
- Generating a Random Number between 1 and 10 Java
- math in java – what does ” %” do?
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- Generating a Random Number between 1 and 10 Java [duplicate]
- How do I generate random integers within a specific range in Java?
- Best way to convert an ArrayList to a string
- How do I analyze a .mdmp file?
- Initialize List
- > in Java
- “No X11 DISPLAY variable” – what does it mean?
- en_US or en-US, which one should you use?
- Does Java support default parameter values?
- javac : command not found
- Java says FileNotFoundException but file exists
- Why am I getting InputMismatchException?
- Java integer list
- How can I properly compare two Integers in Java?
- element not interactable exception in selenium web automation
- How to compare two double values in Java?
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java
- How to override compareTo (Java)
- Reading in from System.in – Java
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- java.util.NoSuchElementException: No line found
- How to check whether a int is not null or empty?
- How to parse JSON in Java
- Declaring an unsigned int in Java
- Converting Hexadecimal String to Decimal Integer
- LocalDate to java.util.Date and vice versa simplest conversion?
- What is WEB-INF used for in a Java EE web application?
- What does the colon (:) operator do?
- Is there an exponent operator in C#?
- Shifting array to the right – homework
- How to get rid of Checkstyle message ‘File does not end with a newline.’
- trying to fix java Exception in thread “JavaFX Application Thread” java.lang.NullPointerException
- Uri not Absolute exception getting while calling Restful Webservice
- Very Basic Java
- SQLRecoverableException: I/O Exception: Connection reset
- What exactly is a Maven Snapshot and why do we need it?
- How to check if my string is equal to null?
- what is Ljava.lang.String;@
- The specified DSN contains an architecture mismatch between the Driver and Application. JAVA
- “Could not find Java SE Runtime Environment.” after installing Java
- How can I create an utility class?
- difference between ‘static int’ and ‘int’ in java
- How to use PrintWriter and File classes in Java?
- Convert hex string to int
- Orphaned Case Error in Java
- Proxy Error 502 : The proxy server received an invalid response from an upstream server
- Java double.MAX_VALUE?
- how to do a system pause in java for debugging?
- Immutable class?
- Is spring default scope singleton or not?
- Java Reflection – Object is not an instance of declaring class
- What does “AL lib: alc_cleanup: 1 device not closed” mean?
- Dice Rolling java program
- int cannot be converted to int []
- Joda DateTime to Timestamp conversion
- break statement in “if else” – java
- How to use Java AWT setBackground
- What is the difference between JSF, Servlet and JSP?
- Get only part of an Array in Java?
- How to Get JSON Array Within JSON Object?
- What is a class constant?
- How to represent a fix number of repeats in regular expression?
- How to import a jar in Eclipse
- JFrame in full screen Java
- How do I break out of nested loops in Java?
- How do I convert this for loop into a while loop?
- Java switch statement: Constant expression required, but it IS constant
- Resolving File paths – ‘File not found’ error in Eclipse
- Simple Coin Toss using random class in Java. The do while loop doesn’t seem to generate random results
- Why I am getting DefaultHttpClient is deprecated?
- When should you use multithreading? And would multi threading be beneficial if the different threads execute mutually independent tasks?
- How to Convert Int to Unsigned Byte and Back
- Suggestions needed: Effective Java to C source code converter
- Downloading a file from spring controllers
- Java Error Exception in thread “AWT-EventQueue-0” java.lang.StackOverflowError
- What is an attribute in Java?
- KeyPressed event in java
- MessageBodyWriter not found for media type=application/json
- Conversion from Long to Double in Java
- Failed to find Java VM
- Java regex email
- What is the equivalent of Java’s System.out.println() in Javascript?
- Java Iterator on Doubly-linked-list
- Why “no projects found to import”?
- Java Swing setting JPanel Size
- how to use “tab space” while writing in text file