Tutorial by Examples

Using the Package Manager JDK and/or JRE releases for OpenJDK or Oracle can be installed using the package manager on most mainstream Linux distribution. (The choices that are available to you will depend on the distro.) As a general rule, the procedure is to open terminal window and run the comm...
The term responsive web design was first coined by Ethan Marcotte in his famous article Responsive Web Design, published in 2010 in A List Apart. This Smashing Magazine article by Kayla Knight describes it as follows: Responsive Web design is the approach that suggests that design and developme...
Let's assume you have a file lyrics.txt which contains the following data: summer has come and passed the innocent can never last wake me up when september ends Read the entire file at a time By using file:read_file(File), you can read the entire file. It's an atomic operation: 1> file:re...
Write one line at a time Open a file with write mode and use io:format/2: 1> {ok, S} = file:open("fruit_count.txt", [write]). {ok,<0.57.0>} 2> io:format(S, "~s~n", ["Mango 5"]). ok 3> io:format(S, "~s~n", ["Olive 12"]). ok 4&gt...
This is a very simple program to create a PDF using iText 7 / Java: //Initialize writer PdfWriter writer = new PdfWriter(dest); //Initialize document PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); //Add paragraph to the document doc.add(new Paragraph(&q...
Introduces the definition of an enumeration type. enum Direction { UP, LEFT, DOWN, RIGHT }; Direction d = UP; C++11 In C++11, enum may optionally be followed by class or struct to define a scoped enum. Furthermore, both scoped and unscoped enums can have their unde...
Only Oracle JDKs and JREs are available for Windows platforms. The installation procedure is straight-forward: Visit the Oracle Java Downloads page: Click on either the JDK button, the JRE button or the Server JRE button. Note that to develop using Java you need JDK. To know the difference betw...
When applied to a single-argument constructor, prevents that constructor from being used to perform implicit conversions. class MyVector { public: explicit MyVector(uint64_t size); }; MyVector v1(100); // ok uint64_t len1 = 100; MyVector v2{len1}; // ok, len1 is uint64_t int len2 ...
Oracle Java 7 and Java 8 Java 7 and Java 8 for macOS are available from Oracle. This Oracle page answers a lot of questions about Java for Mac. Note that Java 7 prior to 7u25 have been disabled by Apple for security reasons. In general, Oracle Java (Version 7 and later) requires an Intel-based Mac...
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"&g...
Sometimes you may need to convert a Set to an array, for example to be able to use Array.prototype methods like .filter(). In order to do so, use Array.from() or destructuring-assignment: var mySet = new Set([1, 2, 3, 4]); //use Array.from const myArray = Array.from(mySet); //use destructuring-a...
There are no build-in methods for intersection and difference in Sets, but you can still achieve that but converting them to arrays, filtering, and converting back to Sets: var set1 = new Set([1, 2, 3, 4]), set2 = new Set([3, 4, 5, 6]); const intersection = new Set(Array.from(set1).filter(x...
You can use a simple for-of loop to iterate a Set: const mySet = new Set([1, 2, 3]); for (const value of mySet) { console.log(value); // logs 1, 2 and 3 } When iterating over a set, it will always return values in the order they were first added to the set. For example: const set = new S...
Suppose you have a pojo class Person public class Person { public String name; public Person(String name) { this.name = name; } } And you want to parse it into a JSON array or a map of Person objects. Due to type erasure you cannot construct classes of List<Person&g...
Table locks can be an important tool for ENGINE=MyISAM, but are rarely useful for ENGINE=InnoDB. If you are tempted to use table locks with InnoDB, you should rethink how you are working with transactions. MySQL enables client sessions to acquire table locks explicitly for the purpose of cooperati...
If we have a file called Business.hs, we can define a Business module that can be import-ed, like so: module Business ( Person (..), -- ^ Export the Person type and all its constructors and field names employees -- ^ Export the employees function ) where -- begin types, function defin...
To export the type and all its constructors, one must use the following syntax: module X (Person (..)) where So, for the following top-level definitions in a file called People.hs: data Person = Friend String | Foe deriving (Show, Eq, Ord) isFoe Foe = True isFoe _ = False This module d...
Haskell supports importing a subset of items from a module. import qualified Data.Stream (map) as D would only import map from Data.Stream, and calls to this function would require D.: D.map odd [1..] otherwise the compiler will try to use Prelude's map function.
Prelude often defines functions whose names are used elsewhere. Not hiding such imports (or using qualified imports where clashes occur) will cause compilation errors. Data.Stream defines functions named map, head and tail which normally clashes with those defined in Prelude. We can hide those impo...
When multiple modules define the same functions by name, the compiler will complain. In such cases (or to improve readability), we can use a qualified import: import qualified Data.Stream as D Now we can prevent ambiguity compiler errors when we use map, which is defined in Prelude and Data.Stre...

Page 724 of 1336