Wednesday, January 16, 2019
Java 8 - Functional Interfaces
Java functional interfaces use cases :
Primitive specializations
Method reference receipt:
Reference : Modern Java In action book
Friday, January 11, 2019
Java performance tuning
Articles
1. Simple tuning : link
2. How to write memory efficient code - Youtube video link
Notes:
* Check the current log level first
This recommendation should be obvious, but unfortunately, you can find lots of code that ignores it. Before you create a debug message, you should always check the current log level first. Otherwise, you might create a String with your log message that will be ignored afterward.
1. Simple tuning : link
2. How to write memory efficient code - Youtube video link
Notes:
* Check the current log level first
This recommendation should be obvious, but unfortunately, you can find lots of code that ignores it. Before you create a debug message, you should always check the current log level first. Otherwise, you might create a String with your log message that will be ignored afterward.
Java throubleshooting
Articles
1. Types of profiles : link , Youtube video
2. How to get high CPU usage in java(thread dump) : link
3. Heap dump analysis, Youtube video : link
4. Article for OutOfMemmoryError : link
Some useful commands
- jps
- jmap -histo:[live] PID -> for historgram
- jmap dump : filename PID -> heap dump
example: jmap -dump:live,format=b,file=/tmp/dump.hprof
- XX:HeapDumpOutOfMemoryError and XX:HeapDumpFileLocation $some_path
1. Types of profiles : link , Youtube video
2. How to get high CPU usage in java(thread dump) : link
3. Heap dump analysis, Youtube video : link
4. Article for OutOfMemmoryError : link
Some useful commands
- jps
- jmap -histo:[live] PID -> for historgram
- jmap dump : filename PID -> heap dump
example: jmap -dump:live,format=b,file=/tmp/dump.hprof
- XX:HeapDumpOutOfMemoryError and XX:HeapDumpFileLocation $some_path
Wednesday, January 2, 2019
String basic formulas
String Basics
A string is traditionally a sequence of characters, either as a literal constant or as some kind of
variable. The latter may allow its elements to be mutated and the length changed, or it may be
fixed (after creation).
variable. The latter may allow its elements to be mutated and the length changed, or it may be
fixed (after creation).
Some languages provide strings as a builtin datatype ( Like C++ , Java , C# ) whereas some
implements string as an array of characters ( Like C ).
implements string as an array of characters ( Like C ).
Strings are not available in C instead, we use a char array to read strings, where the end of string
is marked with the special character
is marked with the special character
\0
often called as null character.
When we have a char arr[] in C and want to iterate over the characters with a loop like
for (int i = 0;i < strlen(arr);i++){
printf("%c",arr[i]) ;
}
we have to be careful because by using strlen(arr), the complexity of the operation goes
unknowingly up to . That is because strlen(arr) is a operation in itself, so it should not be used
in the termination condition.
unknowingly up to . That is because strlen(arr) is a operation in itself, so it should not be used
in the termination condition.
int len = strlen(arr) ;
for (int i = 0;i < len;i++){
printf("%c",arr[i]) ;
}
Substring:
A substring is a part of string such that . It is a contiguous slice of the original string.
For example : List of substrings of string S = "abc" contains following strings.
- a
- b
- c
- ab
- bc
- abc
Therefore, a string of length contains substrings.
Subsequence:
A subsequence is a sequence that can be derived from another sequence by deleting some
elements ( possibly zero but not all ) without changing the order of the remaining elements.
elements ( possibly zero but not all ) without changing the order of the remaining elements.
For example : List of subsequences of string S = "abc" contains following sequences.
- a
- b
- c
- ab
- bc
- ac
- abc
Therefore, a sequence of size contains subsequences.
Subset:
Subset is any unordered set of elements from the original list.
For example : List of subsets of string S = "abc" contains following sets.
- {}
- {a}
- {b}
- {c}
- {c,b}
- {a,b}
- {a,c}
- {a,b,c}
Therefore, a set of size contains subsets.
NOTE :
- {b,a,c} is a subset of string "abc" but not a subsequence.
- Each subsequence of a collection of elements is its subset also, but reverse does not hold.
Sublist:
Sublist is any unordered list derived from the original list. Here elements need not be unique,
but should exist on separate indices in the original list.
Source : Hackerrank.com
but should exist on separate indices in the original list.
Source : Hackerrank.com
Subscribe to:
Posts (Atom)