
how do i write in three integers and output them in order from lowest to highest?? Im very new to java

package corejava;
public class SortThreeIntegers { public static void main(String[] args) { int a,b,c; a=8;b=4;c=7; //If a is the smallest if(a

Try this
public class SortThreeIntegers {
public static void main(String[] args) {
int a,b,c;
//Edit these values as per your need
a=8;b=4;c=7;
//If a is the smallest
if(a < b && a < c){
if(b < c){
System.out.println(a+" "+b+" "+c);
}
else{
System.out.println(a+" "+c+" "+b); }
} //if b is the smallest
else if(b < c && b < a){
if(a < c){
System.out.println(b+" "+a+" "+c);
} else{
System.out.println(b+" "+c+" "+a); }
}
//c is the smallest
else {
if(a < b){
System.out.println(c+" "+a+" "+b);
}
else{
System.out.println(c+" "+b+" "+a);
}
}
}
}

Hi Friend,
You may try the following code:
import java.util.*;
class SortArr
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter Array elements:");
int arr[]=new int[3];
for(int i=0;i<arr.length;i++){
arr[i]=input.nextInt();
}
Arrays.sort(arr);
System.out.println("Array Elements from lowest to highest: ");
for(int i=0;i<arr.length;i++){
System.out.println(arr[i]);
}
}
}
Thanks