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
48f56777
Commit
48f56777
authored
Nov 05, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PrzegladTypow
parent
d174c2e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
PrzegladTypow.java
src/main/java/p01_zmienne/PrzegladTypow.java
+54
-0
No files found.
src/main/java/p01_zmienne/PrzegladTypow.java
0 → 100644
View file @
48f56777
package
p01_zmienne
;
import
java.time.LocalDateTime
;
public
class
PrzegladTypow
{
public
static
void
main
(
String
[]
args
)
{
// 8 typów prostych:
// liczby calkowite: byte, short, int, long
byte
b
=
100
;
short
s
=
1000
;
int
i
=
23
;
long
l
=
333
;
System
.
out
.
println
(
b
*
s
*
i
*
l
);
// 2 typy dla liczb z ułamkiem. liczby "zmiennopozycyjne" / "zmiennoprzeconkowe" (floating point)
float
f
=
3.14
F
;
double
d
=
123.456
;
System
.
out
.
println
(
f
*
d
);
System
.
out
.
println
();
// char - pojedynczy znak, ale patrząc technicznie, to jest liczba 16-bitowa, która może być kodem znaku
char
c
=
'A'
;
System
.
out
.
println
(
c
);
System
.
out
.
println
(
c
+
1
);
// kodem litery A jest 65
c
++;
// teraz jednak "przesuwamy znak" o jedną pozycję do przodu
System
.
out
.
println
(
c
);
boolean
warunek
=
true
;
System
.
out
.
println
(
warunek
);
warunek
=
f
<
3
;
System
.
out
.
println
(
warunek
);
// przy okazji dwa sposoby umieszczania egzotycznych znaków w napisach:
if
(
warunek
)
{
System
.
out
.
println
(
"\u03C0 jest małe"
);
}
else
{
System
.
out
.
println
(
"π jest duże"
);
}
System
.
out
.
println
();
// Typy obiektowe: klasa, interfejs, enum, rekord oraz tablice
// Sama Java definiuje ich kilka tysięcy, a programiści mogą tworzyć własne
String
napis
=
"Ala ma kota"
;
System
.
out
.
println
(
napis
);
System
.
out
.
println
(
napis
.
toUpperCase
());
LocalDateTime
czas
=
LocalDateTime
.
now
();
System
.
out
.
println
(
czas
);
System
.
out
.
println
(
"Godzina "
+
czas
.
getHour
()
+
" minut "
+
czas
.
getMinute
());
// itd, jest tego bardzo dużo
}
}
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