English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Does java has when(not while) loop? I pretty sure it doesn't. I probebly able to make one, but I dont want to make a new class or methoswhich already exist. Once again its when, not while.

2006-10-12 09:18:26 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

lol thats true, i can right if statment, but I wont do like, i mantion that loop one time in program and whenever happens what I said in when loop will happen. For Example, When(pressedX()){dothis();} , So whenever I press X it will do whatever I have mantioned in dothis() . I know Its a difficle que, but thanks for answering.

2006-10-12 14:57:19 · update #1

3 answers

cant u just use an if statment? i dont understand why u needed to ask this question.

2006-10-12 09:50:32 · answer #1 · answered by fishscale 1 · 0 0

right this is how i might do it: for (int i = 10; i > 0; i--) { for (int j = 0; j < i; j++) { device.out.print("*"); } device.out.println(""): } The outer for loop keeps track of what number stars to placed on the present line, it starts from 10 and counts downward. the interior for loop will surely write out the celebrity, and save looping till it hits the kind of stars (from 0 to i) that could desire to be on that line. whilst the interior loop terminates, this technique prints out a sparkling line and is going on from there.

2016-12-13 07:08:37 · answer #2 · answered by pfarr 4 · 0 0

what is the difference?

2006-10-12 09:26:36 · answer #3 · answered by romulusnr 5 · 0 0

fedest.com, questions and answers