FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/ArraySlice/src/arrayslice/Main.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
ArraySlice
/
src
/
arrayslice
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
111 lines (100 loc) · 3.03 KB
Breadcrumbs
java-code-example
/
ArraySlice
/
src
/
arrayslice
/
Main.java
Copy path
File metadata and controls
executable file
·
111 lines (100 loc) · 3.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
arrayslice
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
LinkedList
;
/**
*
* @author cherkashinv
*/
public
class
Main
{
/**
* @param args the command line arguments
*/
public
static
void
main
(
String
[]
args
) {
// check String.equalsIgnoreCase
//String value="true";
//System.out.println(value.equalsIgnoreCase("True"));
/*
byte[] test=new byte[]{10,20,30};
print_array(test);
//print_array(appendBytesToBytes(test,test,test));
check_array(test);
print_array(test);
*/
/*
byte[] test=new byte[]{10,20,30,40,50,60,70};
print_array(Arrays.copyOf(test, 3));
print_array(test);
print_array(Arrays.copyOfRange(test, 3, test.length));
*/
//volatile_class_example();
LinkedList
<
Integer
>
list
=
new
LinkedList
<
Integer
>();
for
(
int
counter
=
0
;
counter
<
10
;
counter
++){
list
.
add
(
new
Integer
(
counter
));
}
list
=
new
LinkedList
(
list
.
subList
(
4
+
1
,
10
));
for
(
int
counter
=
0
;
counter
<
list
.
size
();
counter
++){
System
.
out
.
println
(
list
.
get
(
counter
));
}
}
private
static
void
volatile_class_example
(){
class
Temp
{
private
String
field_name
;
public
Temp
(){
this
.
field_name
=
""
;
}
public
Temp
(
String
value
){
this
.
field_name
=
value
;
}
public
String
getValue
(){
return
this
.
field_name
;
}
}
Temp
temp_value
=
new
Temp
(
">>> value "
);
System
.
out
.
println
(
temp_value
.
getValue
());
}
private
static
void
print_array
(
byte
[]
array
){
System
.
out
.
println
(
array
+
":"
);
for
(
int
counter
=
0
;
counter
<
array
.
length
;
counter
++){
System
.
out
.
print
(
array
[
counter
]+
"; "
);
}
System
.
out
.
println
();
}
public
static
void
check_array
(
byte
[]
array
){
System
.
out
.
println
(
">>>>before:"
);
print_array
(
array
);
array
=
appendBytesToBytes
(
array
,
array
);
System
.
out
.
println
(
">>>>after:"
);
print_array
(
array
);
}
/** получить массив, который является результатом сложения всех массивов */
public
static
byte
[]
appendBytesToBytes
(
byte
[] ...
elements
){
int
position
=
0
;
int
array_length
=
0
;
// create return array
for
(
int
index
=
0
;
index
<
elements
.
length
;
index
++){
if
(
elements
[
index
]!=
null
){
array_length
+=
elements
[
index
].
length
;
}
else
{
// current element is null
}
}
byte
[]
return_value
=
new
byte
[
array_length
];
// copy
for
(
int
index
=
0
;
index
<
elements
.
length
;
index
++){
if
(
elements
[
index
]!=
null
){
for
(
int
counter
=
0
;
counter
<
elements
[
index
].
length
;
counter
++){
return_value
[
position
]=
elements
[
index
][
counter
];
position
++;
}
}
else
{
// current element is null
}
}
return
return_value
;
}
}
Back
|
FazBrowse Home
|
New Git URL