100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Resumen

Summary Learn java

Puntuación
-
Vendido
-
Páginas
23
Subido en
08-02-2025
Escrito en
2024/2025

To learn java practical and theory

Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Libro relacionado

Escuela, estudio y materia

Institución
Grado

Información del documento

¿Un libro?
Subido en
8 de febrero de 2025
Número de páginas
23
Escrito en
2024/2025
Tipo
Resumen

Temas

Vista previa del contenido

Unit-2
Decision Making, Looping, Strings, Arrays and Wrapper Classes
1.1 Flow control statements:-
 If Statements: -
o If statement is used to evaluate a condition.
o The control of program is diverted depending upon the
condition.
o If statement gives a Boolean value either true or false.
o There are four types of if – statements.
i. Simple if : -
o It is the most basic and simple statement.
o It evaluates a Boolean expression and enables the program
to enter a block of code if the expression evaluates to true.
o Syntax: -
if(condition) {
statement 1; //executes when condition is true
}
o Example: -
public class Student
{
public static void main(String[] args)
{
int x = 10;
int y = 12;
if(x+y > 20)
{
System.out.println("x + y is greater than 20");
}
}
}

ii. If-else statement: -
o If else statement is an extension to the if statement, which
uses another block of code is else block.

,o Else block is executed if the condition of the if-block is
evaluated as false.
o Syntax: -
if(condition)
{
statement 1; //executes when condition is true
}
Else
{
statement 2; //executes when condition is false
}
o Example: -

public class Student
{
public static void main(String[] args)
{
int x = 10;
int y = 12;
if(x+y < 10)
{
System.out.println("x + y is less than 10");
}
else
{
System.out.println("x + y is greater than 20");
}
}
}

iii.If-else-if ladder: -
o The if-else-if statement contains the if-statement following
by multiple else-if statements.
o We can say that it is the chain of if-else statements that
create a decision tree where the program may enter in the
block of code where the condition Is true.

, o We can also define an else statement at the end of the
chain.
o Syntax: -
if(condition 1) {
statement 1; //executes when condition 1 is true
}
else if(condition 2) {
statement 2; //executes when condition 2 is true
}
else {
statement 2; //executes when all the conditions are false
}
o Example: -
public class Student
{
public static void main(String[] args)
{
String city = "Delhi";
if(city == "Gandhinagar")
{
System.out.println("city is Gandhinagar ");
}
else if (city == "Noida")
{
System.out.println("city is noida");
}else if(city == "Agra")
{
System.out.println("city is agra");
}
else
{
System.out.println(city);
}
}
}
$8.79
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor
Seller avatar
nensiborad

Documento también disponible en un lote

Conoce al vendedor

Seller avatar
nensiborad nav gujarat
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
0
Miembro desde
10 meses
Número de seguidores
0
Documentos
7
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes