| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index)
|
int |
codePointAt(int index)
|
int |
codePointBefore(int index)
|
int |
codePointCount(int beginIndex,
int endIndex)
|
int |
compareTo(String anotherString)
|
int |
compareToIgnoreCase(String str)
|
String |
concat(String str)
|
boolean |
contains(CharSequence s)
|
boolean |
contentEquals(CharSequence cs)
|
boolean |
contentEquals(StringBuffer sb)
|
static String |
copyValueOf(char[] data)
Equivalent to valueOf(char[]). |
static String |
copyValueOf(char[] data,
int offset, int count)
Equivalent to valueOf(char[],
int, int). |
boolean |
endsWith(String suffix)
|
boolean |
equals(Object anObject)
|
boolean |
equalsIgnoreCase(String anotherString)
|
static String |
format(Locale l,
String format,
Object... args)
Returns a formatted string using the specified locale, format string, and arguments. |
static String |
format(String format,
Object... args)
Returns a formatted string using the specified format string and arguments. |
byte[] |
getBytes()
|
byte[] |
getBytes(Charset charset)
|
void |
getBytes(int srcBegin,
int srcEnd, byte[] dst, int dstBegin)
Deprecated. This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the getBytes()
method, which uses the platform's default charset. |
byte[] |
getBytes(String charsetName)
|
void |
getChars(int srcBegin,
int srcEnd, char[] dst, int dstBegin)
|
int |
hashCode()
|
int |
indexOf(int ch)
|
int |
indexOf(int ch,
int fromIndex)
|
int |
indexOf(String str)
|
int |
indexOf(String str,
int fromIndex)
|
String |
intern()
|
boolean |
isEmpty()
|
static String |
join(CharSequence delimiter,
CharSequence... elements)
|
static String |
join(CharSequence delimiter,
Iterable<?
extends CharSequence> elements)
|
int |
lastIndexOf(int ch)
|
int |
lastIndexOf(int ch,
int fromIndex)
|
int |
lastIndexOf(String str)
|
int |
lastIndexOf(String str,
int fromIndex)
|
int |
length()
|
boolean |
matches(String regex)
|
int |
offsetByCodePoints(int index,
int codePointOffset)
|
boolean |
regionMatches(boolean ignoreCase,
int toffset, String other,
int ooffset, int len)
|
boolean |
regionMatches(int toffset,
String other,
int ooffset, int len)
|
String |
replace(char oldChar,
char newChar)
|
String |
replace(CharSequence target,
CharSequence replacement)
|
String |
replaceAll(String regex,
String replacement)
|
String |
replaceFirst(String regex,
String replacement)
|
String[] |
split(String regex)
|
String[] |
split(String regex,
int limit)
|
boolean |
startsWith(String prefix)
|
boolean |
startsWith(String prefix,
int toffset)
|
CharSequence |
subSequence(int beginIndex,
int endIndex)
|
String |
substring(int beginIndex)
|
String |
substring(int beginIndex,
int endIndex)
|
char[] |
toCharArray()
|
String |
toLowerCase()
|
String |
toLowerCase(Locale locale)
|
String |
toString()
|
String |
toUpperCase()
|
String |
toUpperCase(Locale locale)
|
String |
trim()
|
static String |
valueOf(boolean b)
Returns the string representation of the boolean argument. |
static String |
valueOf(char c)
Returns the string representation of the char
argument. |
static String |
valueOf(char[] data)
Returns the string representation of the char
array argument. |
static String |
valueOf(char[] data,
int offset, int count)
Returns the string representation of a specific subarray of the char array
argument. |
static String |
valueOf(double d)
Returns the string representation of the double argument. |
static String |
valueOf(float f)
Returns the string representation of the float argument. |
static String |
valueOf(int i)
Returns the string representation of the int
argument. |
static String |
valueOf(long l)
Returns the string representation of the long
argument. |
static String |
valueOf(Object obj)
Returns the string representation of the Object
argument. |
2020-03-06
Class String
Interface List
- AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector
Class ArrayList
- All Implemented Interfaces:
- Serializable, Cloneable, Iterable
, Collection , List , RandomAccess
- Direct Known Subclasses:
- AttributeList, RoleList, RoleUnresolvedList
Collections.sort(aList);
aList.sort(null);
A
null value indicates that the elements'
natural ordering should be usedaList.sort((e1,e2) -> e2 - e1); //DESC
boolean |
add(E e)
|
void |
add(int index,
E element)
|
boolean |
addAll(Collection<?
extends E> c)
|
boolean |
addAll(int index,
Collection<?
extends E> c)
|
void |
clear()
|
Object |
clone()
|
boolean |
contains(Object o)
|
void |
ensureCapacity(int minCapacity)
|
void |
forEach(Consumer<?
super E> action)
|
E |
get(int index)
|
int |
indexOf(Object o)
|
boolean |
isEmpty()
|
Iterator<E> |
iterator()
|
int |
lastIndexOf(Object o)
|
ListIterator<E> |
listIterator()
|
ListIterator<E> |
listIterator(int index)
|
E |
remove(int index)
|
boolean |
remove(Object o)
|
boolean |
removeAll(Collection<?> c)
|
boolean |
removeIf(Predicate<?
super E> filter)
|
protected void |
removeRange(int fromIndex,
int toIndex)
|
void |
replaceAll(UnaryOperator<E> operator)
|
boolean |
retainAll(Collection<?> c)
|
E |
set(int index,
E element)
|
int |
size()
|
void |
sort(Comparator<?
super E> c)
|
Spliterator<E> |
spliterator()
|
List<E> |
subList(int fromIndex,
int toIndex)
|
Object[] |
toArray()
|
<T> T[] |
toArray(T[] a)
|
void |
trimToSize()
|
Date & Time
https://docs.oracle.com/javase/tutorial/datetime/TOC.html
The code produces output similar to the following:
LocalDate today = LocalDate.now();
LocalDate dateOfBirth = LocalDate.of(2012, Month.MAY, 14); LocalDate firstBirthday = dateOfBirth.plusYears(1);
LocalTime thisSec;
for (;;) {
thisSec = LocalTime.now();
display(thisSec.getHour(), thisSec.getMinute(), thisSec.getSecond());
}
System.out.printf("now: %s%n", LocalDateTime.now());
System.out.printf("Apr 15, 1994 @ 11:30am: %s%n",
LocalDateTime.of(1994, Month.APRIL, 15, 11, 30));
System.out.printf("now (from Instant): %s%n",
LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()));
System.out.printf("6 months from now: %s%n",
LocalDateTime.now().plusMonths(6));
System.out.printf("6 months ago: %s%n",
LocalDateTime.now().minusMonths(6));
DateTimeFormatter format = DateTimeFormatter.ofPattern("MMM d yyyy hh:mm a");
LocalDateTime leaving = LocalDateTime.of(2013, Month.JULY, 20, 19, 30);
LocalDate date = LocalDate.parse(in, DateTimeFormatter.BASIC_ISO_DATE);
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("MMM d yyyy");
LocalDate date = LocalDate.parse(input, formatter);
Instant t1, t2; ... long ns = Duration.between(t1, t2).toNanos();
Instant start; ... Duration gap = Duration.ofSeconds(10); Instant later = start.plus(gap);
LocalDate today = LocalDate.now();
LocalDate birthday = LocalDate.of(1960, Month.JANUARY, 1);
Period p = Period.between(birthday, today);
long p2 = ChronoUnit.DAYS.between(birthday, today);
System.out.println("You are " + p.getYears() + " years, " + p.getMonths() +
" months, and " + p.getDays() +
" days old. (" + p2 + " days total)");
You are 53 years, 4 months, and 29 days old. (19508 days total)
| Prefix | Method Type | Use |
|---|---|---|
| of | static factory | Creates an instance where the factory is primarily validating the input parameters, not converting them. |
| from | static factory | Converts the input parameters to an instance of the target class, which may involve losing information from the input. |
| parse | static factory | Parses the input string to produce an instance of the target class. |
| format | instance | Uses the specified formatter to format the values in the temporal object to produce a string. |
| get | instance | Returns a part of the state of the target object. |
| is | instance | Queries the state of the target object. |
| with | instance | Returns a copy of the target object with one element changed; this is the immutable equivalent to a set method on a JavaBean. |
| plus | instance | Returns a copy of the target object with an amount of time added. |
| minus | instance | Returns a copy of the target object with an amount of time subtracted. |
| to | instance | Converts this object to another type. |
| at | instance | Combines this object with another. |
https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The following pattern letters are defined:
Symbol Meaning Presentation Examples
------ ------- ------------ -------
G era text AD; Anno Domini; A
u year year 2004; 04
y year-of-era year 2004; 04
D day-of-year number 189
M/L month-of-year number/text 7; 07; Jul; July; J
d day-of-month number 10
Q/q quarter-of-year number/text 3; 03; Q3; 3rd quarter
Y week-based-year year 1996; 96
w week-of-week-based-year number 27
W week-of-month number 4
E day-of-week text Tue; Tuesday; T
e/c localized day-of-week number/text 2; 02; Tue; Tuesday; T
F week-of-month number 3
a am-pm-of-day text PM
h clock-hour-of-am-pm (1-12) number 12
K hour-of-am-pm (0-11) number 0
k clock-hour-of-am-pm (1-24) number 0
H hour-of-day (0-23) number 0
m minute-of-hour number 30
s second-of-minute number 55
S fraction-of-second fraction 978
A milli-of-day number 1234
n nano-of-second number 987654321
N nano-of-day number 1234000000
V time-zone ID zone-id America/Los_Angeles; Z; -08:30
z time-zone name zone-name Pacific Standard Time; PST
O localized zone-offset offset-O GMT+8; GMT+08:00; UTC-08:00;
X zone-offset 'Z' for zero offset-X Z; -08; -0830; -08:30; -083015; -08:30:15;
x zone-offset offset-x +0000; -08; -0830; -08:30; -083015; -08:30:15;
Z zone-offset offset-Z +0000; -0800; -08:00;
p pad next pad modifier 1
' escape for text delimiter
'' single quote literal '
[ optional section start
] optional section end
# reserved for future use
{ reserved for future use
} reserved for future use
2019-12-02
Java Collections
You can not sort TreeMap on values.
Key points about HashSet:
HashSet stores elements in random-order
Allows only unique element/objects with maximum limit of 1 null
Key points about HashSet:
HashSet stores elements in random-order
Allows only unique element/objects with maximum limit of 1 null
2019-11-27
Java Spring Boot MVC
mv application.properties application.yml
spring:
profiles:dev
server:
port:81
---
spring:
profiles:prod
server:
port:80
mvn clean package
java -jar -Dspring.profiles.active=dev target/initial-boot-app-0.0.1-SNAPSHOT.jar
Actuator:
https://www.linkedin.com/learning/spring-boot-essential-training/spring-boot-actuator
localhost:8080/env
/health
/mappings
/health
/metrics
/configprops
/env
/loggers
/mappings
Spring Security
https://www.linkedin.com/learning/spring-boot-essential-training/implementing-spring-security
spring.thymeleaf.cache=false
spring:
profiles:dev
server:
port:81
---
spring:
profiles:prod
server:
port:80
mvn clean package
java -jar -Dspring.profiles.active=dev target/initial-boot-app-0.0.1-SNAPSHOT.jar
Actuator:
https://www.linkedin.com/learning/spring-boot-essential-training/spring-boot-actuator
localhost:8080/env
/health
/mappings
/health
/metrics
/configprops
/env
/loggers
/mappings
Spring Security
https://www.linkedin.com/learning/spring-boot-essential-training/implementing-spring-security
spring.thymeleaf.cache=false
2019-11-26
Java Stream API
Processing Data with Java SE 8 Streams, Part 1
https://www.oracle.com/technical-resources/articles/java/ma14-java-se-8-streams.html
Part 2: Processing Data with Java SE 8 Streams
https://www.oracle.com/technical-resources/articles/java/architect-streams-pt2.html
Package java.util.stream
https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html
Interface Stream
https://docs.oracle.com/javase/8/docs/api/?java/util/stream/Stream.html
https://www.youtube.com/watch?v=t1-YZ6bF-g0
Intermediate operations:
filter
map
flatmap
sort (sorted?)
anyMatch
distinct
findFirst
skip
Terminal operations:
forEach
collect
reduce
count
min
max
summaryStatistics
Stream API,part 1 https://www.youtube.com/watch?v=O8oN4KSZEXE
Intermediate operations:
filter
map
flatmap
peek
sorted
distinct
limit
skip
unordered
parallel
sequential
Terminal operations:
forEach, iterator
find[First|All]
[all|any|non]Match
reduction, collectors
Stream API,part 2 https://www.youtube.com/watch?v=i0Jr2l3jrDA
https://www.oracle.com/technical-resources/articles/java/ma14-java-se-8-streams.html
Part 2: Processing Data with Java SE 8 Streams
https://www.oracle.com/technical-resources/articles/java/architect-streams-pt2.html
Package java.util.stream
https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html
Interface Stream
https://docs.oracle.com/javase/8/docs/api/?java/util/stream/Stream.html
https://www.youtube.com/watch?v=t1-YZ6bF-g0
Intermediate operations:
filter
map
flatmap
sort (sorted?)
anyMatch
distinct
findFirst
skip
Terminal operations:
forEach
collect
reduce
count
min
max
summaryStatistics
Stream API,part 1 https://www.youtube.com/watch?v=O8oN4KSZEXE
Intermediate operations:
filter
map
flatmap
peek
sorted
distinct
limit
skip
unordered
parallel
sequential
Terminal operations:
forEach, iterator
find[First|All]
[all|any|non]Match
reduction, collectors
Stream API,part 2 https://www.youtube.com/watch?v=i0Jr2l3jrDA
2019-11-25
Java Spring Boot Tips
@PropertySource("classpath/application.properties")
@Value("${app_props_key}")
private String app_prop_val;
https://www.linkedin.com/learning/spring-framework-in-depth/implement-aop-advice-before
loggin.level.root=INFO
logMethodCall()
LOGGER.log(app method params
2019-11-14
Java learn & certification
https://docs.oracle.com/javase/tutorial/extra/certification/index.html
https://coderanch.com/c/certification
13 Free Java 8 Certification Online Mock Tests
https://www.java67.com/2017/05/10-free-java-8-certification-sample-questions-OCAJP8-OCPJP8-Mock-Exams.html
https://www.udemy.com/course/spring-boot-complete-guide-from-development-to-deployment/?LSNPUBID=JVFxdTr9V80&ranEAID=JVFxdTr9V80&ranMID=39197&ranSiteID=JVFxdTr9V80-s9R8rW3unDigzKT4CYcaOA
https://javarevisited.blogspot.com/2016/12/5-tips-to-prepare-for-oracle-java-certifications-OCAJP-OCPJP-exams.html?m=1
https://dou.ua/lenta/articles/java-11-developer-1/
2019-10-25
Java stuff
JSON viewer:
http://jsonviewer.stack.hu/
Parse JSON String to Object in Spring Boot App
Automation JS frameworks
https://dou.ua/lenta/articles/automation-js-frameworks/?from=nl&utm_source=20191022&utm_medium=email&utm_campaign=CM
SCRUM
http://scrumy.com
User Interface with Boostrap Learning Module Overview
BufferedReader, InputStream, BufferedInputStream: Overview
Use BufferedReader, BufferedInputStream in Java
HTML View to Controller to Service to DAO
HTML View to Controller to Service to DAO
Thymeleaf th:each and Boostrap list-group integrated
JUnit
Test Driven Design/BDD with Spring Boot Example
Test Driven Development with Spring Boot
Mockito
Use Mockito in Spring Boot to Mock Test Object
Spring Boot essentials
https://www.youtube.com/playlist?list=PL73qvSDlAVVh4QHMkO2gM52deldy64n45
From Zero to Hero with Spring Boot - Brian Clozel
https://linuxize.com/post/install-mariadb-on-centos-7/
AMQP: Asynchronous messaging in Spring Boot applications
https://www.linkedin.com/learning/spring-boot-essential-training/asynchronous-messaging-in-spring-boot-applications
http://jsonviewer.stack.hu/
Parse JSON String to Object in Spring Boot App
Automation JS frameworks
https://dou.ua/lenta/articles/automation-js-frameworks/?from=nl&utm_source=20191022&utm_medium=email&utm_campaign=CM
SCRUM
http://scrumy.com
User Interface with Boostrap Learning Module Overview
BufferedReader, InputStream, BufferedInputStream: Overview
Use BufferedReader, BufferedInputStream in Java
HTML View to Controller to Service to DAO
HTML View to Controller to Service to DAO
Thymeleaf th:each and Boostrap list-group integrated
JUnit
Test Driven Design/BDD with Spring Boot Example
Test Driven Development with Spring Boot
Mockito
Use Mockito in Spring Boot to Mock Test Object
Spring Boot essentials
https://www.youtube.com/playlist?list=PL73qvSDlAVVh4QHMkO2gM52deldy64n45
From Zero to Hero with Spring Boot - Brian Clozel
https://linuxize.com/post/install-mariadb-on-centos-7/
AMQP: Asynchronous messaging in Spring Boot applications
https://www.linkedin.com/learning/spring-boot-essential-training/asynchronous-messaging-in-spring-boot-applications
Spring Data in Spring Boot applications
https://www.linkedin.com/learning/spring-boot-essential-training/spring-data-in-spring-boot-applications
Spring Security in Spring Boot applications
https://www.linkedin.com/learning/spring-boot-essential-training/spring-security-in-spring-boot-applications
2019-10-05
Java PWM monitor
How to Compile Java Programs into EXEs
https://www.youtube.com/watch?v=Mr_TdPuF-4g
How to use ADC in STM32F103C8 - Measuring Analog Voltage
https://circuitdigest.com/microcontroller-projects/how-to-use-adc-in-stm32f103c8-stm32-blue-pill-board
Programming STM32F103C8 Board using USB Port
https://circuitdigest.com/microcontroller-projects/programming-stm32f103c8-board-using-usb-port
Subscribe to:
Posts (Atom)

