#13 Mastering Java | Ternary Operator Explained | Java Tutorial Series | EMC Academy

preview_player
Показать описание
In this episode, we explore the ternary operator in Java, a powerful tool for concise conditional expressions. Join us at EMC Academy as we break down its syntax, discuss its applications, and provide hands-on examples to deepen your understanding. Whether you're new to programming or looking to enhance your Java skills, this tutorial is designed to help you grasp this essential concept with ease.

Java in Tamil.

Join our 700K+ Instagram community
Рекомендации по теме
Комментарии
Автор

public class Ternary {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
String result=(a>b)?"A is greater":"B is greater";
System.out.println(result);
}

PreethiPriyadharshini
Автор

Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
String result = a>b? "A is greater than b" : "b is greater than a";
System.out.println(result);

Akash-wkph
Автор

class Ternary{
public static void main(String[] args){
int a =18;
int b = 30;
String result = a >=b ? "a is greater than b" : "b is greater than a";
System.out.print(result);
}
}

guruseelan
Автор

public static void main(String[] args) {
int a= 10;
int b=20;
String result =a<b?"Greater":"lessthan";
System.out.println(result);

}

gopir
Автор

Import java.lang. System;
Import java. util. Scanner;

Class hello{
Public static void main (String args[]){
Scanner demo = New Scanner (System.in);
System.out. println("Enter a value a:");
Int a = demo. nextInt();
System. out. Println("Enter a value b:");
Int b = demo. nextInt();
String result = a>b? "A is greater":"B is greater";
System.out. println(result);
}
}

balu-exoj
Автор

String result4=(num1>num2)?num1+" is greater than "+num2:num2+" is greater than "+num1;

SivaV-dvpe
Автор

class terr
{
public static void main(String[] args)
{
int a= 23;
int b= 44;
String result = (a>b) ?"a is the greaatest value":"b is the greatest value";

}
}

RamanaViswamithiran
Автор

Bro completed
import java.util.Scanner;

public class demo {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
String result = a>b? "A is greater than b" : "b is greater than a";
System.out.println(result);
}
}

ragavendrar
Автор

package Java;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.println("Enter two interger numbers we will announce which one is greater one");
int a = input.nextInt();
int b = input.nextInt();

System.out.println((a>b) ? a+" is greater number" : b+" is greater number");
}
}

Mr.Aravindhan
Автор

import java.util.Scanner;

public class practice {
public static void main(String args[]){
Scanner scan=new Scanner(System.in);
System.out.print("Enter the number1: ");
int num1=scan.nextInt();
System.out.print("Enter the number2: ");
int num2=scan.nextInt();
is greater":"number2 is greater");
}
}

aravindh
Автор

Sir is this answer correct

import java.lang.System;
import java.util.Scanner;

class one {
public static void main(String[] args) {

Scanner hello = new Scanner(System.in);
System.out.println("Enter A...");
int a = hello.nextInt();
System.out.println("Enter B...");
int b = hello.nextInt();
String value = a > b ? "A is greater than B" : "B is greater than A";
System.out.println(value);
}

}

nvsbflims
Автор

System.out.println("Enter a number A");
int a = sc.nextInt();
System.out.println("Enter a number B");
int b = sc.nextInt();

String result = a>b?"A is greatest Number" :"B is greatest Number";

System.out.println(result);

worldofgokulan
Автор

I completed
Bro Upload MySQL Full course

Dhakshina_Moorthy
Автор

Why the notes document is not accessible????

nivethasri
Автор

very useful bro.. Apdiye Java with selenium webdriver and cucumber BDD framework with POM videos panunga bro romba usefull ah irukum

varunjoseph
Автор

{Scanner scan =new Scanner (System.in);
int a =scan.nextInt();
int b =scan.nextInt();
System.out.print(a>b? "A is greater" : "B is greater");

suthimj
Автор

class HelloWorld {
public static void main(String[] args) {
int a=5;
int b=4;
String result=a>b?"a is greater":"b is greater";
System.out.println(result);
}
}

KeerthiKeerthi-rgdv
Автор

import java.util.Scanner;
class surya{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
String check = a > b? a+ " is greater" : b+ " is greater";
System.out.print(check);
}

}

logusurya
Автор

import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();

int num2 = sc.nextInt();

String result = num1>num2?"num 1 is greater":"num2 is greater";
System.out.print(result);
}
}

sportszone
Автор

import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
System.out.print(a>b?"a is greater":"b is greater");
}
}

mohamedarsath