Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20231104-KursPodstawowyALX
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20231104-KursPodstawowyALX
Commits
579e6ee7
Commit
579e6ee7
authored
Nov 18, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
przykład break continue
parent
8a94d4ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
BreakContinue_Prezentacja.java
...main/java/p05_petle/teoria/BreakContinue_Prezentacja.java
+32
-0
No files found.
src/main/java/p05_petle/teoria/BreakContinue_Prezentacja.java
0 → 100644
View file @
579e6ee7
package
p05_petle
.
teoria
;
import
javax.swing.JOptionPane
;
public
class
BreakContinue_Prezentacja
{
public
static
void
main
(
String
[]
args
)
{
int
licznik
=
0
;
while
(
true
)
{
licznik
++;
JOptionPane
.
showInternalMessageDialog
(
null
,
"Początek pętli, licznik = "
+
licznik
);
int
odp1
=
JOptionPane
.
showConfirmDialog
(
null
,
"Czy zrobić break?"
);
if
(
odp1
==
JOptionPane
.
YES_OPTION
)
{
break
;
// break w pętli powoduje natychmiastowe zakończenie tej pętli i przejście do następnej instrukcji za pętlą
}
JOptionPane
.
showInternalMessageDialog
(
null
,
"Środek pętli. Nie było break."
);
int
odp2
=
JOptionPane
.
showConfirmDialog
(
null
,
"Czy zrobić continue?"
);
if
(
odp2
==
JOptionPane
.
YES_OPTION
)
{
continue
;
// continue powoduje pominięcie reszty instrukcji w bieżącym obrocie pętli
// i przejście od razu na początek następnego obrotu
}
JOptionPane
.
showInternalMessageDialog
(
null
,
"Koniec pętli, nie było break ani continue"
);
}
JOptionPane
.
showInternalMessageDialog
(
null
,
"Koniec programu"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment