- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to get the maximum of three long values
Firstly, let us declare and initialize three long values −
long val1 = 98799; long val2 = 98567; long val3 = 98768;
Now, find the maximum of three long values using the following condition −
// checking for maximum if (val2 > val1) { val1 = val2; } if (val3 > val1) { val1 = val3; }
The following is the complete example to get the maximum value −
Example
public class Demo { public static void main(String[] args) { long val1 = 98799; long val2 = 98567; long val3 = 98768; // displaying System.out.println("Number 1 = "+val1); System.out.println("Number 2 = "+val2); System.out.println("Number 3 = "+val3); // checking for maximum if (val2 > val1) { val1 = val2; } if (val3 > val1) { val1 = val3; } System.out.println("The greatest of three numbers: "+val1); } }
Output
Number 1 = 98799 Number 2 = 98567 Number 3 = 98768 The greatest of three numbers: 98799
- Related Articles
- Java program to get the minimum of three long values
- Display the maximum of three integer values in Java
- Java program to find maximum of three numbers
- Java Program to get maximum value with Comparator
- Python program maximum of three.
- C# program to find the maximum of three numbers
- Python program to find the maximum of three numbers
- Java Program to Get Minimum and Maximum From a List
- Java program to Sort long Array
- Display the minimum of three integer values in Java
- Get the set of values in Java IdentityHashMap
- Java Program to get the reverse of the NavigableSet
- Java Program to Get the Size of the Collection
- Assigning long values carefully in java to avoid overflow\n
- Python program to get maximum of each key Dictionary List

Advertisements