Tutorial by Examples: and

Android Studio is the Android development IDE that is officially supported and recommended by Google. Android Studio comes bundled with the Android SDK Manager, which is a tool to download the Android SDK components required to start developing apps. Installing Android Studio and Android SDK tools:...
It is possible to define an array with more than one dimension. Instead of being accessed by providing a single index, a multidimensional array is accessed by specifying an index for each dimension. The declaration of multidimensional array can be done by adding [] for each dimension to a regular a...
For basic prototypes or basic command-line behavior, the following loop comes in handy. public class ExampleCli { private static final String CLI_LINE = "example-cli>"; //console like string private static final String CMD_QUIT = "quit"; //string for exit...
As you use generic types with utility classes, you may often find that number types aren't very helpful when specified as the object types, as they aren't equal to their primitive counterparts. List<Integer> ints = new ArrayList<Integer>(); Java SE 7 List<Integer> ints = new A...
Executors accept a java.lang.Runnable which contains (potentially computationally or otherwise long-running or heavy) code to be run in another Thread. Usage would be: Executor exec = anExecutor; exec.execute(new Runnable() { @Override public void run() { //offloaded work, no need t...
Server: Start, and wait for incoming connections //Open a listening "ServerSocket" on port 1234. ServerSocket serverSocket = new ServerSocket(1234); while (true) { // Wait for a client connection. // Once a client connected, we get a "Socket" object // that c...
Once we've gotten the Connection, we will mostly use it to create Statement objects. Statements represent a single SQL transaction; they are used to execute a query, and retrieve the results (if any). Let's look at some examples: public void useConnection() throws SQLException{ Connection ...
Enum can be considered to be syntax sugar for a sealed class that is instantiated only a number of times known at compile-time to define a set of constants. A simple enum to list the different seasons would be declared as follows: public enum Season { WINTER, SPRING, SUMMER, FA...
An enum can contain a method, just like any class. To see how this works, we'll declare an enum like this: public enum Direction { NORTH, SOUTH, EAST, WEST; } Let's have a method that returns the enum in the opposite direction: public enum Direction { NORTH, SOUTH, EAST, WEST; ...
wait() and notify() work in tandem – when one thread calls wait() on an object, that thread will block until another thread calls notify() or notifyAll() on that same object. (See Also: wait()/notify() ) package com.example.examples.object; import java.util.concurrent.atomic.AtomicBoolean; p...
Parentheses are now forbidden around named parameters. The following compiles in C#5, but not C#6 5.0 Console.WriteLine((value: 23)); Operands of is and as are no longer allowed to be method groups. The following compiles in C#5, but not C#6 5.0 var result = "".Any is byte; T...
There are many ways to create arrays. The most common are to use array literals, or the Array constructor: var arr = [1, 2, 3, 4]; var arr2 = new Array(1, 2, 3, 4); If the Array constructor is used with no arguments, an empty array is created. var arr3 = new Array(); results in: [] Note...
Start by defining a Foo function that we'll use as a constructor. function Foo (){} By editing Foo.prototype, we can define properties and methods that will be shared by all instances of Foo. Foo.prototype.bar = function() { return 'I am bar'; }; We can then create an instance using the ...
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) { //parse the response in xhttp.responseText; } }; xhttp.open("GET", "ajax_info.txt", true); xhttp.send(...
echo and print are language constructs, not functions. This means that they don't require parentheses around the argument like a function does (although one can always add parentheses around almost any PHP expression and thus echo("test") won't do any harm either). They output the string r...
Unlike in languages like Python, static properties of the constructor function are not inherited to instances. Instances only inherit from their prototype, which inherits from the parent type's prototype. Static properties are never inherited. function Foo() {}; Foo.style = 'bold'; var foo = ne...
The map function is the simplest one among Python built-ins used for functional programming. map() applies a specified function to each element in an iterable: names = ['Fred', 'Wilma', 'Barney'] Python 3.x3.0 map(len, names) # map in Python 3.x is a class; its instances are iterable # Out: &...
print_r() - Outputting Arrays and Objects for debugging print_r will output a human readable format of an array or object. You may have a variable that is an array or object. Trying to output it with an echo will throw the error: Notice: Array to string conversion. You can instead use the print_r...
Arguments are passed to the program in a manner similar to most C-style languages. $argc is an integer containing the number of arguments including the program name, and $argv is an array containing arguments to the program. The first element of $argv is the name of the program. #!/usr/bin/php p...
When run from the CLI, the constants STDIN, STDOUT, and STDERR are predefined. These constants are file handles, and can be considered equivalent to the results of running the following commands: STDIN = fopen("php://stdin", "r"); STDOUT = fopen("php://stdout", "...

Page 3 of 153