Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_20251009
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
alx_20251009
Commits
086e1f9b
Commit
086e1f9b
authored
Oct 09, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mutowalnosc
parent
82a1abea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
Mutowalnosc1.java
src/main/java/p02_obiekty/Mutowalnosc1.java
+40
-0
Mutowalnosc2.java
src/main/java/p02_obiekty/Mutowalnosc2.java
+29
-0
No files found.
src/main/java/p02_obiekty/Mutowalnosc1.java
0 → 100644
View file @
086e1f9b
package
p02_obiekty
;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
Mutowalnosc1
{
static
void
metoda1
(
int
a
,
Integer
b
,
AtomicInteger
c
)
{
System
.
out
.
println
(
"Początek metody"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
System
.
out
.
println
(
"c: "
+
c
);
a
+=
1
;
b
+=
2
;
// technicznie: b = Integer.valueOf(b.intValue() + 2);
// żeby zrozumieć: b = new Integer(b.intValue() + 2);
// w dalszej części metody w b jest dowiązanie do innego obiektu, niż obiekt widziany z maina
// AtomicInteger to "mutowalna" wersja Integer
c
.
incrementAndGet
();
c
.
addAndGet
(
2
);
System
.
out
.
println
(
"\nKoniec metody"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
System
.
out
.
println
(
"c: "
+
c
);
}
static
void
main
()
{
int
a
=
100
;
Integer
b
=
200
;
AtomicInteger
c
=
new
AtomicInteger
(
300
);
metoda1
(
a
,
b
,
c
);
System
.
out
.
println
(
"\nKoniec main"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
}
}
src/main/java/p02_obiekty/Mutowalnosc2.java
0 → 100644
View file @
086e1f9b
package
p02_obiekty
;
public
class
Mutowalnosc2
{
static
void
metoda1
(
String
a
,
StringBuilder
b
)
{
System
.
out
.
println
(
"Początek metody"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
a
+=
" ma kota"
;
// technicznie: a = new String(a + " ma kota");
b
.
append
(
" ma psa"
);
System
.
out
.
println
(
"\nKoniec metody"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
}
static
void
main
()
{
String
a
=
"Ala"
;
StringBuilder
b
=
new
StringBuilder
(
"Ola"
);
metoda1
(
a
,
b
);
System
.
out
.
println
(
"\nKoniec main"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
}
}
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