Tutorial by Examples: and

Casting an instance of a base class to a subclass as in : b = (B) a; is called narrowing (as you are trying to narrow the base class object to a more specific class object) and needs an explicit type-cast. Casting an instance of a subclass to a base class as in: A a = b; is called widening and does...
Random and ThreadLocalRandom are good enough for everyday use, but they have a big problem: They are based on a linear congruential generator, an algorithm whose output can be predicted rather easily. Thus, these two classes are not suitable for cryptographic uses (such as key generation). One can ...
/** * returns a array of random numbers with no duplicates * @param range the range of possible numbers for ex. if 100 then it can be anywhere from 1-100 * @param length the length of the array of random numbers * @return array of random numbers with no duplicates. */ public static int[] ...
Add React to your project: meteor npm install --save react react-dom react-mounter Create the client/helloworld.jsx file to display a simple React component: import React, { Component } from 'react'; import { mount } from 'react-mounter'; // This component only renders a paragraph containin...
The navigation bar (at the bottom of the screen) can be transparent. Here is the way to achieve it. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:windowTranslucentNavigation">true</item> </style> The Status Bar (t...
Example from the standard library (core.clj:807): (defmacro and "Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last e...
The Comparable<T> interface requires one method: public interface Comparable<T> { public int compareTo(T other); } And the Comparator<T> interface requires one method: public interface Comparator<T> { public int compare(T t1, T t2); } These two met...
Variables declared inside a function only exist (unless passed) inside that function. x <- 1 foo <- function(x) { y <- 3 z <- x + y return(z) } y Error: object 'y' not found Variables passed into a function and then reassigned are overwritten, but only insi...
Environments in R can be explicitly call and named. Variables can be explicitly assigned and call to or from those environments. A commonly created environment is one which encloses package:base or a subenvironment within package:base. e1 <- new.env(parent = baseenv()) e2 <- new.env(parent ...
Functions and objects in different packages may have the same name. The package loaded later will 'mask' the earlier package and a warning message will be printed. When calling the function by name, the function from the most recently loaded package will be run. The earlier function can be accessed ...
If you're writing a class that manages resources, you need to implement all the special member functions (see Rule of Three/Five/Zero). The most direct approach to writing the copy constructor and assignment operator would be: person(const person &other) : name(new char[std::strlen(other.n...
var A var is a reference variable, similar to variables in languages like Java. Different objects can be freely assigned to a var, so long as the given object has the same type that the var was declared with: scala> var x = 1 x: Int = 1 scala> x = 2 x: Int = 2 scala> x = "foo...
Implementing two-way-data-binding, to achieve the result from the previous example, could be done with two core functions: $digest is called after a user interaction (binding DOM=>variable) $watch sets a callback to be called after variable changes (binding variable=>DOM) note: this is ...
CSS resets take separate approaches to browser defaults. Eric Meyer’s Reset CSS has been around for a while. His approach nullifies many of the browser elements that have been known to cause problems right off the back. The following is from his version (v2.0 | 20110126) CSS Reset. html, body, di...
string strCmdText = "/C copy /b Image1.jpg + Archive.rar Image2.jpg"; System.Diagnostics.Process.Start("CMD.exe",strCmdText); This is to hide the cmd window. System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo...
int[string] wordCount(string[] wordList) { int[string] words; foreach (word; wordList) { words[word]++; } return words; } void main() { int[string] count = wordCount(["hello", "world", "I", "say", "hello"]); ...
In medical imaging, spectroscopy, image processing, cryptography and other areas of science and engineering it is often the case that one wishes to compute multidimensional Fourier transforms of images. This is quite straightforward in Matlab: (multidimensional) images are just n-dimensional matrice...
It is possible to save a Docker container's filesystem contents to a tarball archive file. This is useful in a pinch for moving container filesystems to different hosts, for example if a database container has important changes and it isn't otherwise possible to replicate those changes elsewhere. Pl...
Query syntax and method syntax are semantically identical, but many people find query syntax simpler and easier to read. Let’s say we need to retrieve all even items ordered in ascending order from a collection of numbers. C#: int[] numbers = { 0, 1, 2, 3, 4, 5, 6 }; // Query syntax: IEnumerab...
Autoboxing can come at a substantial memory overhead. For example: Map<Integer, Integer> square = new HashMap<Integer, Integer>(); for(int i = 256; i < 1024; i++) { square.put(i, i * i); // Autoboxing of large integers } will typically consume substantial amount of memory (...

Page 45 of 153