Map<String, Object> map = ...;
The solution uses map.keySet(), map.values(), and map.entrySet().
Map<String, Object> map = ...;
![]() |
| Desired Output of the Combined System |
long startTime = System.currentTimeMillis();
doReallyLongThing(); // call your method here
long endTime = System.currentTimeMillis();
// calculate the difference - that the method just took to executeSystem.out.println("That took " + (endTime - startTime) + " milliseconds");
| TOPIC | TEXT | SYNTAX | Example |
|---|---|---|---|
| ARRAY_GET | Returns one element of an array. | ARRAY_GET(arrayExpression, indexExpression) | |
| ARRAY_LENGTH | Returns the length of an array. | ARRAY_GET(arrayExpression) | |
| AUTOCOMMIT | Returns true if auto commit is switched on for this session. | AUTOCOMMIT() | |
| CANCEL_SESSION | Cancels the currently executing statement of another session. | CANCEL_SESSION(sessionInt) | |
| CASEWHEN Function | Returns 'a' if the boolean expression is true, otherwise 'b'. | CASEWHEN(boolean, aValue, bValue) | |
| CAST | Converts a value to another data type. | CAST(value AS dataType) | |
| COALESCE | Returns the first value that is not null. | COALESCE(aValue, bValue [,...]) | |
| CONVERT | Converts a value to another data type. | CONVERT(value, dataType) | |
| CURRVAL | Returns the current (last) value of the sequence, independent of the session. | CURRVAL( [ schemaName, ] sequenceString ) | |
| CSVREAD | Returns the result set of reading the CSV (comma separated values) file. | CSVREAD(fileNameString [, columnsString [, csvOptions ] ] ) | |
| CSVWRITE | Writes a CSV (comma separated values). | CSVWRITE ( fileNameString, queryString [, csvOptions [, lineSepString] ] ) | |
| DATABASE | Returns the name of the database. | DATABASE() | |
| DATABASE_PATH | Returns the directory of the database files and the database name, if it is file based. | DATABASE_PATH() | |
| FILE_READ | Returns the contents of a file. | FILE_READ(fileNameString [,encodingString]) | |
| GREATEST | Returns the largest value that is not NULL, or NULL if all values are NULL. | GREATEST(aValue, bValue [,...]) | |
| IDENTITY | Returns the last inserted identity value for this session. | IDENTITY() | |
| IFNULL | Returns the value of 'a' if it is not null, otherwise 'b'. | IFNULL(aValue, bValue) | |
| LEAST | Returns the smallest value that is not NULL, or NULL if all values are NULL. | LEAST(aValue, bValue [,...]) | |
| LOCK_MODE | Returns the current lock mode. | LOCK_MODE() | |
| LOCK_TIMEOUT | Returns the lock timeout of the current session (in milliseconds). | LOCK_TIMEOUT() | |
| LINK_SCHEMA | Creates table links for all tables in a schema. | LINK_SCHEMA(targetSchemaString, driverString, urlString, userString, passwordString, sourceSchemaString) | |
| MEMORY_FREE | Returns the free memory in KB (where 1024 bytes is a KB). | MEMORY_FREE() | |
| MEMORY_USED | Returns the used memory in KB (where 1024 bytes is a KB). | MEMORY_USED() | |
| NEXTVAL | Returns the next value of the sequence. | NEXTVAL ( [ schemaName, ] sequenceString ) | |
| NULLIF | Returns NULL if 'a' is equals to 'b', otherwise 'a'. | NULLIF(aValue, bValue) | |
| READONLY | Returns true if the database is read-only. | READONLY() | |
| ROWNUM | Returns the number of the current row. | ROWNUM() | |
| SCHEMA | Returns the name of the default schema for this session. | SCHEMA() | |
| SCOPE_IDENTITY | Returns the last inserted identity value for this session for the current scope. | SCOPE_IDENTITY() | |
| SESSION_ID | Returns the unique session id number for the current database connection. | SESSION_ID() | |
| SET | Updates a variable with the given value. | SET(@variableName, value) | |
| TABLE | Returns the result set. | { TABLE | TABLE_DISTINCT } ( { name dataType = expression } [,...] ) | |
| TRANSACTION_ID | Returns the current transaction id for this session. | TRANSACTION_ID() | |
| USER | Returns the name of the current user of this session. | { USER | CURRENT_USER } () | Select User(); |
| TOPIC | TEXT | SYNTAX | Example |
|---|---|---|---|
| CURRENT_DATE | Returns the current date. | { CURRENT_DATE [ () ] | CURDATE() | SYSDATE | TODAY } | |
| CURRENT_TIME | Returns the current time. | { CURRENT_TIME [ () ] | CURTIME() } | |
| CURRENT_TIMESTAMP | Returns the current timestamp. | { CURRENT_TIMESTAMP [ ( [ int ] ) ] | NOW( [ int ] ) } | |
| DATEADD | Adds units to a timestamp. | DATEADD(unitString, addInt, timestamp) | |
| DATEDIFF | Returns the the number of crossed unit boundaries between two timestamps. | { DATEDIFF | TIMESTAMPDIFF } (unitString, aTimestamp, bTimestamp) | |
| DAYNAME | Returns the name of the day (in English). | DAYNAME(date) | |
| DAY_OF_MONTH | Returns the day of the month (1-31). | DAY_OF_MONTH(date) | |
| DAY_OF_WEEK | Returns the day of the week (1 means Sunday). | DAY_OF_WEEK(date) | |
| DAY_OF_YEAR | Returns the day of the year (1-366). | DAY_OF_YEAR(date) | |
| EXTRACT | Returns a specific value from a timestamps. | EXTRACT ( { YEAR | YY | MONTH | MM | DAY | DD | DAY_OF_YEAR | DOY | HOUR | HH | MINUTE | MI | SECOND | SS | MILLISECOND | MS } FROM timestamp ) | |
| FORMATDATETIME | Formats a date, time or timestamp as a string. | FORMATDATETIME ( timestamp, formatString [ , localeString [ , timeZoneString ] ] ) | |
| HOUR | Returns the hour (0-23) from a timestamp. | HOUR(timestamp) | |
| MINUTE | Returns the minute (0-59) from a timestamp. | MINUTE(timestamp) | |
| MONTH | Returns the month (1-12) from a timestamp. | MONTH(timestamp) | |
| MONTHNAME | Returns the name of the month (in English). | MONTHNAME(date) | |
| PARSEDATETIME | Parses a string and returns a timestamp. | PARSEDATETIME(string, formatString [, localeString [, timeZoneString]]) | |
| QUARTER | Returns the quarter (1-4) from a timestamp. | QUARTER(timestamp) | |
| SECOND | Returns the second (0-59) from a timestamp. | SECOND(timestamp) | |
| WEEK | Returns the week (1-53) from a timestamp. | WEEK(timestamp) | |
| YEAR | Returns the year from a timestamp. | YEAR(timestamp) |
BufferedImage image = new BufferedImage(component.getWidth(),
component.getHeight(), BufferedImage.TYPE_INT_RGB);
// paints into image's Graphics
component.paint(image.getGraphics());
Save Image :| TOPIC | TEXT | SYNTAX | Example |
|---|---|---|---|
| ASCII | Returns the ASCII value of the first character in the string. | ASCII(string) | |
| BIT_LENGTH | Returns the number of bits in a string. | BIT_LENGTH(string) | |
| LENGTH | Returns the number of characters in a string. | { LENGTH | CHAR_LENGTH | CHARACTER_LENGTH } ( string ) | |
| OCTET_LENGTH | Returns the number of bytes in a string. | OCTET_LENGTH(string) | |
| CHAR | Returns the character that represents the ASCII value. | { CHAR | CHR } ( int ) | |
| CONCAT | Combines strings. | CONCAT(string, string [,...]) | |
| DIFFERENCE | Returns the difference between the sounds of two strings. | DIFFERENCE(string, string) | |
| HEXTORAW | Converts a hex representation of a string to a string. | HEXTORAW(string) | |
| RAWTOHEX | Converts a string to the hex representation. | RAWTOHEX(string) | |
| INSTR | Returns the location of a search string in a string. | INSTR(string, searchString, [, startInt]) | |
| INSERT Function | Inserts a additional string into the original string at a specified start position. | INSERT(originalString, startInt, lengthInt, addString) | |
| LOWER | Converts a string to lowercase. | { LOWER | LCASE } ( string ) | |
| UPPER | Converts a string to uppercase. | { UPPER | UCASE } ( string ) | |
| LEFT | Returns the leftmost number of characters. | LEFT(string, int) | |
| RIGHT | Returns the rightmost number of characters. | RIGHT(string, int) | |
| LOCATE | Returns the location of a search string in a string. | LOCATE(searchString, string [, startInt]) | |
| POSITION | Returns the location of a search string in a string. | POSITION(searchString, string) | |
| LPAD | Left pad the string to the specified length. | LPAD(string, int[, paddingString]) | |
| RPAD | Right pad the string to the specified length. | RPAD(string, int[, paddingString]) | |
| LTRIM | Removes all leading spaces from a string. | LTRIM(string) | |
| RTRIM | Removes all trailing spaces from a string. | RTRIM(string) | |
| TRIM | Removes all leading spaces, trailing spaces, or spaces at both ends, from a string. | TRIM ( [ { LEADING | TRAILING | BOTH } [ string ] FROM ] string ) | |
| REGEXP_REPLACE | Replaces each substring that matches a regular expression. | REGEXP_REPLACE(inputString, regexString, replacementString) | |
| REPEAT | Returns a string repeated some number of times. | REPEAT(string, int) | |
| REPLACE | Replaces all occurrences of a search string in a text with another string. | REPLACE(string, searchString [, replacementString]) | |
| SOUNDEX | Returns a four character code representing the sound of a string. | SOUNDEX(string) | |
| SPACE | Returns a string consisting of a number of spaces. | SPACE(int) | |
| STRINGDECODE | Converts a encoded string using the Java string literal encoding format. | STRINGDECODE(string) | |
| STRINGENCODE | Encodes special characters in a string using the Java string literal encoding format. | STRINGENCODE(string) | |
| STRINGTOUTF8 | Encodes a string to a byte array using the UTF8 encoding format. | STRINGTOUTF8(string) | |
| SUBSTRING | Returns a substring of a string starting at a position. | { SUBSTRING | SUBSTR } ( string, startInt [, lengthInt ] ) | |
| UTF8TOSTRING | Decodes a byte array in the UTF8 format to a string. | UTF8TOSTRING(bytes) | |
| XMLATTR | Creates an XML attribute element of the form "name=value". | XMLATTR(nameString, valueString) | |
| XMLNODE | Create an XML node element. | XMLNODE(elementString [, attributesString [, contentString]]) | |
| XMLCOMMENT | Creates an XML comment. | XMLCOMMENT(commentString) | |
| XMLCDATA | Creates an XML CDATA element. | XMLCDATA(valueString) | |
| XMLSTARTDOC | The string " | XMLSTARTDOC() | |
| XMLTEXT | Creates an XML text element. | XMLTEXT(valueString) |
public static String padRight(String s, int n) {
return String.format("%1$-" + n + "s", s); }
public static String padLeft(String s, int n) {
return String.format("%1$#" + n + "s", s); }
...
public static void main(String args[]) throws Exception {
System.out.println(padRight("Howto", 20) + "*");
System.out.println(padLeft("Howto", 25) + "*");
}
public String reverse(String str) {
if ((null == str) || (str.length() <= 1)) {
return str;
}
return reverse(str.substring(1)) + str.charAt(0);
}
public class JdkReverser implements Reverser {
public String reverse(String str) {
if ((null == str) || (str.length() <= 1)) {
return str;
}
return new StringBuffer(str).reverse().toString();
}
}
| Function | Description | SYNTAX | Example |
|---|---|---|---|
| ABS | Returns the absolute value of a number. | ABS ( { int | long | decimal | double } ) | SELECT ABS(-10) returns 10 |
| ACOS | Returns the arc cosine of a value in radians. | ACOS(double) | SELECT ACOS(0.5) returns 1.0472... |
| ASIN | Returns the arc sine of a value in radians. | ASIN(double) | SELECT ASIN(0.5) returns 0.5236... |
| ATAN | Returns the arc tangent of a value in radians. | ATAN(double) | SELECT ATAN(1) returns 0.7854... |
| COS | Returns the cosine of an angle (radians). | COS(double) | SELECT COS(0) returns 1.0 |
| COT | Returns the cotangent of an angle (radians). | COT(double) | SELECT COT(1) returns 0.6421... |
| SIN | Returns the sine of an angle (radians). | SIN(double) | SELECT SIN(0) returns 0.0 |
| TAN | Returns the tangent of an angle (radians). | TAN(double) | SELECT TAN(0) returns 0.0 |
| ATAN2 | Returns the arc tangent of y/x, using the signs to determine the quadrant. | ATAN2(double, double) | SELECT ATAN2(1, 0) returns 1.5708... |
| BITAND | The bitwise AND operation. | BITAND(long, long) | SELECT BITAND(5, 3) returns 1 |
| BITOR | The bitwise OR operation. | BITOR(long, long) | SELECT BITOR(5, 3) returns 7 |
| BITXOR | The bitwise XOR operation. | BITXOR(long, long) | SELECT BITXOR(5, 3) returns 6 |
| MOD | The modulo operation. | MOD(long, long) | SELECT MOD(7, 3) returns 1 |
| CEILING | Returns the smallest integer >= the argument. | CEILING(double) | SELECT CEILING(2.3) returns 3 |
| DEGREES | Converts radians to degrees. | DEGREES(double) | SELECT DEGREES(PI()) returns 180 |
| EXP | Returns e raised to the power of the argument. | EXP(double) | SELECT EXP(1) returns 2.718... |
| FLOOR | Returns the largest integer <= the argument. | FLOOR(double) | SELECT FLOOR(2.7) returns 2 |
| LOG | Returns the natural logarithm (base e). | LOG(double) | SELECT LOG(1) returns 0.0 |
| LOG10 | Returns the base‑10 logarithm. | LOG10(double) | SELECT LOG10(100) returns 2.0 |
| RADIANS | Converts degrees to radians. | RADIANS(double) | SELECT RADIANS(180) returns 3.14159... |
| SQRT | Returns the square root. | SQRT(double) | SELECT SQRT(9) returns 3.0 |
| PI | Returns the mathematical constant π. | PI() | SELECT PI() returns 3.14159... |
| POWER | Raises the first argument to the power of the second. | POWER(double, double) | SELECT POWER(2, 3) returns 8.0 |
| RAND | Calling the function without parameter returns the next a pseudo random number. With a seed, the sequence becomes deterministic. | RAND( [ int ] ) | SELECT RAND() returns 0.730... |
| RANDOM_UUID | Returns a new UUID with 122 pseudo random bits. | RANDOM_UUID() | SELECT RANDOM_UUID() returns 'a0eebc99-9c...' |
| ROUND | Rounds to a number of digits. Positive digits round to decimal places, negative to powers of ten. | ROUND(double, digitsInt) | SELECT ROUND(2.345, 2) returns 2.35 |
| ROUNDMAGIC | This function rounds numbers in a good way, but it is slow. Uses a more mathematically correct rounding algorithm (half‑even). | ROUNDMAGIC(double) | SELECT ROUNDMAGIC(2.5) returns 2 (half-even) |
| SECURE_RAND | Generates an array of cryptographically secure random bytes. The argument specifies the number of bytes. | SECURE_RAND(int) | SELECT SECURE_RAND(8) returns [B@1a2b3c... |
| SIGN | Returns -1 if the value is smaller 0, 0 if zero, and otherwise 1. | SIGN ( { int | long | decimal | double } ) | SELECT SIGN(-45) returns -1 |
| ENCRYPT | Encrypts data using a key. The algorithm string can be 'AES', 'DES', etc. | ENCRYPT(algorithmString, keyBytes, dataBytes) | SELECT ENCRYPT('AES', '0123456789abcdef', 'my data') |
| DECRYPT | Decrypts data using a key. Must match the encryption algorithm and key. | DECRYPT(algorithmString, keyBytes, dataBytes) | SELECT DECRYPT('AES', '0123456789abcdef', encrypted_bytes) |
| HASH | Calculate the hash value using an algorithm, and repeat this process for a number of iterations. Useful for key derivation. | HASH(algorithmString, dataBytes, iterationInt) | SELECT HASH('SHA256', 'hello', 1000) |
| TRUNCATE | Truncates to a number of digits (to the next value closer to 0). | TRUNCATE(double, digitsInt) | SELECT TRUNCATE(2.345, 2) returns 2.34 |
| COMPRESS | Compresses the data using the specified compression algorithm. If algorithm is omitted, default is 'LZF'. | COMPRESS(dataBytes [, algorithmString]) | SELECT COMPRESS('Hello world', 'LZF') |
| EXPAND | Expands data that was compressed using the COMPRESS function. | EXPAND(bytes) | SELECT EXPAND(compressed_bytes) |
| ZERO | Returns the value 0. Useful as a placeholder when a constant zero is needed. | ZERO() | SELECT ZERO() returns 0 |