*$
+
%
))
)
2
)
%
,int[] array = new int[8]
"
)
array[3] = 7
!
"
"
# $ % "
null& 0&
"
)
)
%
$% "
%
"
"
#
"
)
#
&
(
2
static
$
)
$
.0 )
%
)) &
&
)
"
"
"
%
5
+
1
% "
(
"
)
'
- %
=
)
4$
7 & 7 8& 7 9& 7
!
)
! ,: )
"
!
:
;
) -
$
1 %
4
#
)
%
, #
% " # "
0 #
% "
3
#
.& .03 .
)
,
4
'(2
22 6(2
'
)
for& while
if
% " ,) &
)
" &)
&
$% "
"
%
,
$
2
0
" 1 %
!
+
##
%&#
$%
" ,%
" ,-
,-
%
0$ "
)
)
.
/
false
'
( )
#
Std.out.println(”längd: ” + array.length)
.%
% $
3)) # #
"
class Summera {
public static void
int[] array1 =
int[] array2 =
int[] summa =
$
"
# "
4$
#
main(String[] args) {
{ 13, -22, 82, 17, 31, 11, 40, -100, -12, 1};
{-12, 24, -79, -13, -1, -1, 49,
7, 310, 9};
new int[10];
% "
array2
#
%
)
$
summa
"
%
array1
summa
<= 5 >
System.out.println("Summor: ");
4
}
}
%$
% "
summa
'
=
)
$ "
4
*
3)) #
!
4
(
3)) #
%#
!
4
%$ "
(
)
%
#
(
%
,
%
#
,)
)
Punkt
"
%#
%$
"
""
#
)
5" #
" %
%
( Punkt=
% " #
#
%
%
int&
double[] array = new double[10];
?@&
)
" A
array[-1] = 5;
!!;
(! B @C2* *0 #
Hur många tal vill du skriva in?
4
Skriv in 4 tal:
8
5
1
2
9
Sorterade:
1
2
5
8
9
Hur många tal vill du skriva in?
4
Skriv in 4 tal:
1
10
2
20
Det näst största är 10
(
# = "
#
array[10] = 5;
(! B @C2* *0&
array[n] = 5;
@ *B 2
(! B
%
"8
)
%
"
)
array
%
nDA
n E array.length
array[0.5] = 5
!!;
(! B @?'F !(2 *0
"
%
int
array[”text”] = 5;
!!;
(! B @?'F !(2 *0
"
%
int
,
@C2* *0&
A
%
#
( Punkt=
% " #
#
%
,
"8
)
Punkt[] femhorning;
! null
B
"
Punkt
Punkt[] punktArray;
%
)
)
"
femhorning = new Punkt[5];
!
null null null null null
#
femhorning[2] = new Punkt(3, 4);
!
null null
null null
F$
& > & >:
%
#
%
( Punkt=
% " #
#
,
%
"8
)
null null
F$
"
,-
'
GG
%
=
$
5
F$
&:
)
%
& >A& >A
F$
F$ & > & >:
F$
& >5& >:
'
(
"
String=
=
%
)
&
"
&
"
"
"
"
&
"
=
)
)
%
"
B "
"
"
"
"
"#
"
%
( ,
' "
}
"
)
2
}
public static void main(String[] args) {
String[] dagar = { ”ma”, ”ti”, ”on”, ”to”, ”fr”, ”lo”, ”so” };
rotera(dagar);
GG
"
%
, - )
"
GG *$
% %
dagar "
for (int i=0; i<7; i++)
Std.out.println(dagar[i]);
}
#
"
"
)
#
'
#
"
#
"
F$ & >5& >A
& >:& >5
class Rotera {
public static void rotera(String[] array) {
)
#
$
,
2
3)) #
%
)
"
" "
2
4
%
!
#
femhorning[2].skrivUt();
)
Punkt[] femhorning = { new Punkt(0, 0), new Punkt(1, 4),
new Punkt(2, 4), new Punkt(4, 2),
new Punkt(2, 0) };
& > & >:
"
,
"
B
"
null null
B
%
#$
)
Punkt[] femhorning;
femhorning = new Punkt[5];
femhorning[2] = new Punkt(3, 4);
!
#
"$
"
H
#
,
#
)
)
%!
.
main
"
!
"
rotera
.
&
'
"
"
"#
"
"
'
&
"$
&
'& '
&
&
'
'
&
&
'& '
' '
' '
'( '
=
'
C
$% "
%
$% "
.
%
)
%
"
)
$
&
"
)
#
#
"
"$,,
/
A5:IJ9K
%
,
-
%
"
,
double[][] avstand = new double[3][2];
,
%
" %
"
double[][] avstand = new double[3][2];
(&
(
$
.
&
4
/0
$ +
$
%
"
) double[]&
double[]=%
,
;% "
"
+
#,
)
%"
double[][] avstand = { { 71, 460 },
{ 619, 276 },
{ 1239, 1583 } };
.4(
2
5
1 2
avstand[0] = new double[3];
!
&
"
"%
avstand
$
B % "
(&
(
& 12
/&
"
,
!
4
,$$ 3 #
#
,$$
!
"
"
&
% "
$
" %
4
& 5="
$
,
%
"
& !
* &
"%
/
)
)
,
!
" %
%
"
(
,
%
%
"
"%
)
, "
int=
"
$
,
(
"
int=
.
#
2 #
)
3)) #
4
$
=
!
(&
!
$
%
(&
$ +
$
+
#,
)
)
"
3)) #
F
"
#
"
%
"
%
%
#
"
"
4%
?%
,
class avstand {
public static void main(String[] args) {
double[][] avstand = { { 71, 460 },
{ 619, 276 },
{ 1239, 1583 } };
GG
"
$
avstand
}
1 %
# "
F
String
Math
#$
java.util.Vector
"
#$
java.util.Arrays
javax.swing.*
#
% "
$
$)) - %
- )
% ,"
4
#
%
"
% "
%
)
double[][][][] array4 = new double[1][2][3][4];
double[][][] array3 =
{ { { 0.1, 0.2 }, { 0.3, 0.4 } },
{ { 1.1, 1.2 }, { 1.3, 1.4 } },
{ { 5.1, 6.2 }, { 7.3, 8.4 } } };
% $ 5
Std.out.println(array3[1][0][1]); GG
%
}
4
1 %
"
"
%
# "
1 %
"
#
"
)
java.lang
'
java.util
&
"
java.io
$
JJJ # "
#
$ "
4
$ "
& .$))
#
% ,
+
" #$
" "
%
.
%
#
$ $
)
http://java.sun.com/javase/6/docs/api/