Tutorial by Examples

import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/hello") public class HelloWorldResource { public static final String MESSAGE = "Hello World!"; @GET @Produces("text/plain") public String getHello() { ...
There are two types of events emitted by a Preferences object: PreferenceChangeEvent and NodeChangeEvent. PreferenceChangeEvent A PreferenceChangeEvent gets emitted by a Properties object every time one of the node's key-value-pairs changes. PreferenceChangeEvents can be listened for with a Prefer...
Preferences objects always represent a specific node in a whole Preferences tree, kind of like this: /userRoot ├── com │   └── mycompany │   └── myapp │   ├── darkApplicationMode=true │   ├── showExitConfirmation=false │   └── windowMaximized=true └── org └...
All instances of Preferences are always thread-safe across the threads of a single Java Virtual Machine (JVM). Because Preferences can be shared across multiple JVMs, there are special methods that deal with synchronizing changes across virtual machines. If you have an application which is supposed...
Preferences nodes can be exported into a XML document representing that node. The resulting XML tree can be imported again. The resulting XML document will remember whether it was exported from the user or system Preferences. To export a single node, but not its child nodes: Java SE 7 try (Output...
Preferences nodes can be imported from a XML document. Importing is meant to be used in conjunction with the exporting functionality of Preferences, since it creates the correct corresponding XML documents. The XML documents will remember whether they were exported from the user or system Preferenc...
Event listeners can be removed again from any Properties node, but the instance of the listener has to be kept around for that. Java SE 8 Preferences preferences = Preferences.userNodeForPackage(getClass()); PreferenceChangeListener listener = evt -> { System.out.println(evt.getKey() + ...
A value of a Preferences node can be of the type String, boolean, byte[], double, float, int or long. All invocations must provide a default value, in case the specified value is not present in the Preferences node. Preferences preferences = Preferences.userNodeForPackage(getClass()); String som...
To store a value into the Preferences node, one of the putXXX() methods is used. A value of a Preferences node can be of the type String, boolean, byte[], double, float, int or long. Preferences preferences = Preferences.userNodeForPackage(getClass()); preferences.put("someKey", "...
Preferences can be used to store user settings that reflect a user's personal application settings, e.g. their editor font, whether they prefer the application to be started in full-screen mode, whether they checked a "don't show this again" checkbox and things like that. public class Exi...
A very common guideline in object oriented design is "as little as possible but as much as necessary". This also applies to the strategy pattern: It is usually advisable to hide implementation details, for example which classes actually implement strategies. For simple strategies which do...
Note that all bitwise operations operate on 32-bit integers by passing any operands to the internal function ToInt32. Bitwise or var a; a = 0b0011 | 0b1010; // a === 0b1011 // truth table // 1010 | (or) // 0011 // 1011 (result) Bitwise and a = 0b0011 & 0b1010; // a === 0b0010 // t...
Iterators and pointers pointing into an std::vector can become invalid, but only when performing certain operations. Using invalid iterators/pointers will result in undefined behavior. Operations which invalidate iterators/pointers include: Any insertion operation which changes the capacity of...
CASE's shorthand variant evaluates an expression (usually a column) against a series of values. This variant is a bit shorter, and saves repeating the evaluated expression over and over again. The ELSE clause can still be used, though: SELECT Id, ItemId, Price, CASE Price WHEN 5 THEN 'CHEAP' ...
When calling a function without an explicit namespace qualifier, the compiler can choose to call a function within a namespace if one of the parameter types to that function is also in that namespace. This is called "Argument Dependent Lookup", or ADL: namespace Test { int call(int i)...
The struct template std::pair can bundle together exactly two return values, of any two types: #include <utility> std::pair<int, int> foo(int a, int b) { return std::make_pair(a+b, a-b); } With C++11 or later, an initializer list can be used instead of std::make_pair: C++11 ...
void Main() { unsafe { int[] a = {1, 2, 3}; fixed(int* b = a) { Console.WriteLine(b[4]); } } } Running this code creates an array of length 3, but then tries to get the 5th item (index 4). On my machine, this printed 1910457872, bu...
Classes are identifiers for the elements that they are assigned to. Use the class attribute to assign a class to an element. <div class="example-class"></div> To assign multiple classes to an element, separate the class names with spaces. <div class="class1 class2&...
The ID attribute of an element is an identifier which must be unique in the whole document. Its purpose is to uniquely identify the element when linking (using an anchor), scripting, or styling (with CSS). <div id="example-id"></div> You should not have two elements with th...
To add an image to a page, use the image tag. Image tags (img) do not have closing tags. The two main attributes you give to the img tag are src, the image source and alt, which is alternative text describing the image. <img src="images/hello.png" alt="Hello World"> Yo...

Page 70 of 1336