> Tech > Figure 2 : Exemple de code Java

Figure 2 : Exemple de code Java

Tech - Par Renaud ROSSET - Publié le 24 juin 2010
email

Defining and initializing variables

int counter;
String customerLastName;
int loopLimit = 5;
MyClass myObjectTwo = new MyClass( );
float myVariable = 7.2;
CustomerName myNameVariable = new CustomerName("Sharon Hoffman");

Manipulating variables

counter = 0;
customerLastName = new String("Last");
customerLastName = new String(lastName);
displayName = (displayName + " " + customerMiddleInitial +

« . « );

Arithmetic operations

counter = (counter +1);
nextCustomerNumber = (nextCustomerNumber +1);
outputPremium = (inputPremium * 2);

Logical comparisons

(counter <= loopLimit)
(counter == 0)
(!customerMiddleInitial.equals(" "))

Looping (do...while)

do
{
/*
* do while loop processing goes here
*/
}
while(i < 8);
Looping (for)
for(int x = 0; x<5; x= (x+1))
{
/*
* for loop processing goes here
*/
}

Branching

if (!customerMiddleInitial.equals(" "))
{
displayName.append(" ").append(customerMiddleInitial).append(". ");
}
else
{
displayName.append(" ");
}

Input

InputStreamReader myInput = new InputStreamReader(System.in);
BufferedReader myBuffer = new BufferedReader(myInput);
String myInputString = new String();
try
{
myInputString = (myBuffer.readLine());
}
catch(IOException exc)
{
/*
* error handling goes here
*/
}

Output

System.out.println("Hello World");

Téléchargez cette ressource

Rapport mondial 2025 sur la réponse à incident

Rapport mondial 2025 sur la réponse à incident

Dans ce nouveau rapport, les experts de Palo Alto Networks, Unit 42 livrent la synthèse des attaques ayant le plus impacté l'activité des entreprises au niveau mondial. Quel est visage actuel de la réponse aux incidents ? Quelles sont les tendances majeures qui redessinent le champ des menaces ? Quels sont les défis auxquels doivent faire face les entreprises ? Découvrez les top priorités des équipes de sécurité en 2025.

Tech - Par Renaud ROSSET - Publié le 24 juin 2010