Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
Scarica il documento per vederlo tutto.
vuoi
o PayPal
tutte le volte che vuoi
I
split/I stuingle
stuinga
la
stuinga i
in un arway
,
. "Io specificate)
alta
di delimitatore
"
crispondenza un
METODI AstraTE
Astrati E Classi
Nomeclasses
case
Abstract /I
Abstract nomemetodo
tipo ;
↑ solzasità
delle devemo
astrati
metodi util
astrate
classi classi
nelle
↓ essere
commete estendono astwatta
le quella
ARRAY tipoes Array
public/private Nome ;
dichiarato della classe
sostrutture
Va nel come :
DIMENSIONE
This TIPO
NOMEARRAY NEW
=
. nell'
Per il
estwave contenuto
valore alway :
(indice assegnato variabile
sarà alla
valore
tipo >
Nomearray e
variabile -
= all'awway
Per value
assegnare un :
SINDICES VALOREDAASSEGNARE
NOMEARRAY =
Per stampone :
away
un StringBuilder()
STRINGBUILDEr New
Stringa ;
=
Append("")
Stringa ;
. it J
(inti i
%
For <Nomearray
0 Length
= ;
. (is)
Append(nome
Stringa array ;
. LENGTH-1/4
: (NOMEARRAY
I . "I
Append("
Stringa ;
,
.
~
↑ Append("y")
Stringa ;
. kuasformave tipo stuing
String
Stringa in
to - neu
;
. costuire
costuisce stuingBuilder flessibile
Si stringa
oggetto che più
serve
un una
a
interi
away di s
= esempio un
weave
:
INT) ARRAX
NOME ; (5)
NOMEARRAY NEW INT ;
=
annive INTES]
NEW
Inte ;
NomeArray = valowi
Peu dei
inizialitarlo con 58
51
Intes h
Nomearray 3
2 ;
= , ,
, ,
Peu l'arway
iteuave : in)
& for(Inti i Length
0 NomeArray
<
= ; ;
.
(Nomearrasis)
System printen
Out ;
. .
↓
& considerando inter
di NUMER
alway
un
numeriy
/Int
For numero : /Numerosi
PRINTIN
Out
System . .
I
DATE E ORE il
deve pacchetto
importare
Si LocalDatetime
Java
Import Time ;
.
.
.
JAVA Java abientato
Linguaggio
:
Come funziona
computer usano codice macchina (basso livello) binario 00000001 00000010 oggetti
agli
00000011 00000100
noi scriviamo source code (alto livello) in file •java
java viene poi compilato ovvero tradotto in codice macchina
quando però compiliamo il codice è specifico per il sistema operativo (Mac,
Windows ecc..)
java mette a disposizione uno step intermedio
source code --› compiler --› byte code --> jvm --> machine code
JVM: java virtual machine è contenuto nel JDK JDK: java development kit che
contiene JRE
JRE: java runtime environment contiene librerie e toolkits
public class Maint
Run | Debug
public static void main(String[] args){
System.out-println(**");
Prima Classe MAIN
mains PRINCIPALE
METUDO DI ENTRATA
Public Class
RUN/DEBUG argey
string()
static
public main
void
↑
↑
PER STAMPARE oggeto")
printi"
System out ;
. .
PER MANDARE STAMPA
A NELLA
CAPO :
oggeto")
printini"
1) System Out ;
. . im"
& l'oggetto
Out
System .
.
COMMENT
Il COMMENTO
VARIABILI valdue
contengono
- un
in +
creazione x
: ;
assegnazione us
: ;
x =
inizializzazione contemporanea X 34
int
in
creatione assegnazione
e
: = ;
/ FALSE
BOOLEAN TRUE
>
-
Peu gave infot utente :
IMPORT SCANNER
JAVA UTIL :
. .
mains
Public Class
RUN/DEBUG argey
string()
static
public main
void In)
(system
Scanner Nel scanner
scanner = ;
.
NEXTLINEI
STRING NOME SCANNER :
= .
stampa concatenatenatione Cognome)
"
+
/"Ciao"
printen +
+ Nome
System Out ;
.
.
= CON NUMERI
I Inti)
scanner Next
Int Eta ;
= .
Nextline) dopo
altrimenti input
puembe
>
scanner +
mon
.
= da divisione
il /liamato modula
di
vesto una
X+
INCREMENTO : ;
DECREMENTO : X-- ; * * 2;
2))
1(y x)
esempio (
X
Int Risultato +
+
: = -
CLASSE MATH dei contri matematici
metodi
Math tuovano svolgere
e per
=> . assolute
valobue ABS
Math
: .
minimo valquadw
esponenti P
.
Pow
Min Max sart
:
massimo
s :
:
:
(MATH PI)
PRINTIN
esempio System Out ;
: . .
OPERATORI COMPARAZIONE
DI risultate
boolean 310
semir ;
: =
/risultatel Java false
Out Mintem
system ·
. (3710) dava falso
Minten
Ort
system
esempio : .
. =1!
3
1
7
, =, =
= =
1
, 1 ↑
diversa
ugwate
LOGIC LAND
OPERATORI &&
booleam % 0
3
3110
esempio ==
2
x = ;
: 1/
Or = =!
NOT
CONDIZIONI
If
& booleam
> Isonline
esempis true i
= : =
(
lisoncive)
If online")
"
! e
System printen
Out ;
. .
S In
↳ "
stamperà online
(condizione
· If
=
Else --
!
jelse
---
scond
if
else =
· if if
Yelse condig
Seig
... Condizioness
If )
annidati
· Ifi
= condizione
120
a
...
S "Buongiorno"
? "Ciao"
=
operator 33.10
terNary esempio stwing
· X : ;
=
: /33 (10 vena
la
è conficiare
cian è vera
se
X è è
buongiorno galsa
se
X "Luca"
Nome
esempio
SWITCH String
: =
: ;
(nome
Switch
"Luca"
Case :
- -
BREAK CAS
;
In "i
CASE ....
---
BREAM : verifica
si casa
>
default Se messum
: non
-
↓ switche fedua
tallo si
=> il
break
il usire .
cast
peu se
serve contatore
T
Inti
=> esempio
While 0
Giaco : = ; sis condizione
(i
While la
< >
-
(i) verificata
nieme prima
Printen
System Out ;
. .
it+;
~
Do
WHILE :
Do OUTIPRINTINI dopo
verificata
viene
SISTEM condizione
la
,
.
i +
i
+
Twie rico) ; incremento
> /inizializzazione
for condizione
o for
g) e = , ,
.... quanti
sappiamo i
> solitamente cioli
quando
si
- usa sono
massimi
?
Forlinti ins ~
it
esempio 0 ;
;
=
: PRINTIN(i)
Out
System ;
.
.
j
di numer
ARREY insieme
: sof
(10
int() tutti della
30 numeri
i lista
>
esempio no
20
Numeri legge
-
=
: ,
, ;
, ,
NUMERIS il due sta leggendo
INT
FOR chiamo
NUMERO numero
: e
(NUMERO)
SYSTEM ;
OUT PRINTIN numero
come
.
.
~ arway
gli
bi no sold
gave con
ich
/gour
il sicls
BREAK = Nompe
ARRAY bati
collezioni di
Gli 3
int storia
voto
auway sono 6)
13
= int) votisturia
voturstoria 5
Int =s = , ,
6
Int voTuzstoria =
Le
Gli lungliezza
away in Java gissa
sono
int) INTJ3) inter
elementi
casi
NUMERI di
si
NEW
esempis vuoto 3
: avvay
crea un
= ;
10 posizione
↑
(0) indizi Legli
NUMERI 10
= ;
(1) da
=> partens
Gli
20
NUMER neus
awway
;
=
(2)
NUMERI 30 ;
= (Numeri (1)
Printen
System Out ;
. . 409
210 valoui
direttamente
si
20 30
Numeri i
Int + auway
crea
; un
= con
, , , quantità di nell'auway
elementi
NUMERI. degli
lunglvezza
LENGTH >
alway -
Length-11)
(Numeri
(Numeri l'ultimo
da
printen
Out >
system numero
es ;
: -
.
. .
multidimensionali
ARRAY 2D orway
a string(51(3)
string(1)
10 modo classi New
=
↑ ↑*
T steutenli
3
studenti Sclassi classe
x
Classi Può VEDERE
.
5 COME
Una matrice
, o
(0)(0) o Mima
alummo classe
1
cassi ABELLA
↑
=...
Class(0)(1) alunno
20 Classe
Mima 2
1
O
=...
(0142] = A(18)
%
10 1CLAS
Cass 2
AL
O
. . . .
/ .
S A(20
°
10
... Al2(AS
/ 2
1
(1140) 10 -
seconda A(3(as
classe
alummo
10
classi 2
=.... ...
---
abummi
Peu tutti gli
vedere : cassety
FORINT Length
classe salassi
Casse O
= ; ;
.
PRINTIN/1
Out
System i
.
. S
studente
jeassey
for(Int (classi Length
studente o stud
; ,
= . .
....
- =
String(1)
20 classi
modo : ....,
" "
Er "
" , is seasse
... ,
... I
J creasse
. . . /
S o classe
3
...
S ;
abummi
Peu tutti gli
vedere : 1
classif
FOR/string() classe : Li
fipe
Altwe il
for
gou :
-- (
classe)
for(string studente :
j
G
=> maiscale/minuscola
è sensibile
stuing
le cavattere a
"Leomaude"
string Nome
es : = ;
EQUALS/"ecomondo") gaese
-
RISULTATO
BOOCEAN NOME
= . CASE/"leamonda" twe
EQUALSIGNORE >
BOOLEA -- = ... -
.
lungleta
Length
nome
>
- . (le
(f)
Count partens
in
Cow Wisvetate cowattere +
positione
nome pos
>
> -
=
- . . of
da
Val
indexof(va") si la
trova
clue posizione
in
nome.
>
- fue
/I è ruota
stuinga
Isempty la
> nome
- ;
. false vota
è
nom
momefoluppeucase()
risultato
sting tutte
> maiuscolo
- ,
Falower /I