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
817147f8
Commit
817147f8
authored
Jan 27, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
poprawki w gotowych
parent
b39dd039
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
5 deletions
+7
-5
Polimorfizm1.java
src/main/java/gotowe/p27_generyki/kolekcje/Polimorfizm1.java
+1
-2
ParaLiczb.java
.../gotowe/p27_generyki/v4_para_liczb_extends/ParaLiczb.java
+1
-1
Test2.java
...java/gotowe/p27_generyki/v4_para_liczb_extends/Test2.java
+4
-1
PrzykladRefleksji.java
src/main/java/gotowe/p29_refleksja/PrzykladRefleksji.java
+1
-1
No files found.
src/main/java/gotowe/p27_generyki/kolekcje/Polimorfizm1.java
View file @
817147f8
...
...
@@ -35,8 +35,7 @@ public class Polimorfizm1 {
}
/** Zamienia pierwszy element z ostatnim i zwraca ich średnią */
/** Zamienia pierwszy element z ostatnim i zwraca ich średnią */
static
<
T
extends
Number
>
double
sredniaZZamiana
(
List
<
T
>
lista
)
{
T
pierwszy
=
lista
.
get
(
0
);
T
ostatni
=
lista
.
get
(
lista
.
size
()-
1
);
...
...
src/main/java/gotowe/p27_generyki/v4_para_liczb_extends/ParaLiczb.java
View file @
817147f8
...
...
@@ -4,7 +4,7 @@ import java.util.Objects;
// Za pomocą ograniczeń "extends" oraz "super" możemy wymusić, że parametr typowy
// spełnia pewne warunki.
// W tym przypadku T extends Number oznacza, że T to może byc Number, Integer, Double itd., ale nie String, Object czy inne typy
// W tym przypadku T extends Number oznacza, że T to może byc Number, Integer, Double
, BigDecimal
itd., ale nie String, Object czy inne typy
public
class
ParaLiczb
<
T
extends
Number
>
{
private
T
lewy
;
private
T
prawy
;
...
...
src/main/java/gotowe/p27_generyki/v4_para_liczb_extends/Test2.java
View file @
817147f8
...
...
@@ -6,6 +6,9 @@ public class Test2 {
public
static
void
main
(
String
[]
args
)
{
ParaLiczb
<
Integer
>
para1
=
new
ParaLiczb
<>(
new
Integer
(
13
),
new
Integer
(
3000
));
ParaLiczb
<
Integer
>
para1a
=
new
ParaLiczb
<>(
13
,
3000
);
ParaLiczb
<
Integer
>
para1b
=
new
ParaLiczb
<>(
Integer
.
valueOf
(
13
),
Integer
.
valueOf
(
3000
));
System
.
out
.
println
(
para1
);
Number
lewy
=
para1
.
getLewy
();
...
...
@@ -13,7 +16,7 @@ public class Test2 {
//NK para1.setLewy(new Double(3.14));
para1
.
setLewy
(
new
Integer
(
44
)
);
para1
.
setLewy
(
44
);
// Wiedząc, że jest to para liczb, mogę korzystać z operacji matematycznych
double
avg
=
para1
.
getSrednia
();
...
...
src/main/java/gotowe/p29_refleksja/PrzykladRefleksji.java
View file @
817147f8
...
...
@@ -27,7 +27,7 @@ public class PrzykladRefleksji {
}
try
{
Class
<?>
klasa3
=
Class
.
forName
(
"
pcz
.p29_refleksja.klasy.Osoba"
);
Class
<?>
klasa3
=
Class
.
forName
(
"
gotowe
.p29_refleksja.klasy.Osoba"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
...
...
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