Tutorial by Examples: c

This Activity code will provide basic functionality for including a Google Map using a SupportMapFragment. The Google Maps V2 API includes an all-new way to load maps. Activities now have to implement the OnMapReadyCallBack interface, which comes with a onMapReady() method override that is execute...
Map Style Google Maps come with a set of different styles to be applied, using this code : // Sets the map type to be "hybrid" map.setMapType(GoogleMap.MAP_TYPE_HYBRID); The different map styles are : Normal map.setMapType(GoogleMap.MAP_TYPE_NORMAL); Typical road map. Roads, s...
The shared remote interface: package remote; import java.rmi.Remote; import java.rmi.RemoteException; public interface RemoteServer extends Remote { int stringToInt(String string) throws RemoteException; } The server implementing the shared remote interface: package server; im...
You should be careful when comparing floating-point values (float or double) using relational operators: ==, !=, < and so on. These operators give results according to the binary representations of the floating point values. For example: public class CompareTest { public static void main...
Annotation @XmlAccessorType determines whether fields/properties will be automatically serialized to XML. Note, that field and method annotations @XmlElement, @XmlAttribute or @XmlTransient take precedence over the default settings. public class XmlAccessTypeExample { @XmlAccessorType(XmlAccessT...
Annotations @XmlElement, @XmlAttribute or @XmlTransient and other in package javax.xml.bind.annotation allow the programmer to specify which and how marked fields or properties should be serialized. @XmlAccessorType(XmlAccessType.NONE) // we want no automatic field/property marshalling public cla...
The + symbol can mean three distinct operators in Java: If there is no operand before the +, then it is the unary Plus operator. If there are two operands, and they are both numeric. then it is the binary Addition operator. If there are two operands, and at least one of them is a String, then i...
The Java language provides 7 operators that perform arithmetic on integer and floating point values. There are two + operators: The binary addition operator adds one number to another one. (There is also a binary + operator that performs string concatenation. That is described in a separate e...
To create your own Iterable as with any interface you just implement the abstract methods in the interface. For Iterable there is only one which is called iterator(). But its return type Iterator is itself an interface with three abstract methods. You can return an iterator associated with some coll...
PrinterJob pJ = PrinterJob.createPrinterJob(); if (pJ != null) { boolean success = pJ.printPage(some-node); if (success) { pJ.endJob(); } } This prints to the default printer without showing any dialog to the user. To use a printer other than the default you can use th...
var person = new Person { Address = null; }; var city = person.Address.City; //throws a NullReferenceException var nullableCity = person.Address?.City; //returns the value of null This effect can be chained together: var person = new Person { Address = new Address { ...
You can use Scanner to read all of the text in the input as a String, by using \Z (entire input) as the delimiter. For example, this can be used to read all text in a text file in one line: String content = new Scanner(new File("filename")).useDelimiter("\\Z").next(); System.o...
You can use custom delimiters (regular expressions) with Scanner, with .useDelimiter(","), to determine how the input is read. This works similarly to String.split(...). For example, you can use Scanner to read from a list of comma separated values in a String: Scanner scanner = null; tr...
Overview In this example 2 clients send information to each other through a server. One client sends the server a number which is relayed to the second client. The second client halves the number and sends it back to the first client through the server. The first client does the same. The server st...
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...
Interfaces can be extremely helpful in many cases. For example, say you had a list of animals and you wanted to loop through the list, each printing the sound they make. {cat, dog, bird} One way to do this would be to use interfaces. This would allow for the same method to be called on all of th...
The JavaScriptSerializer.Deserialize<T>(input) method attempts to deserialize a string of valid JSON into an object of the specified type <T>, using the default mappings natively supported by JavaScriptSerializer. using System.Collections; using System.Web.Script.Serialization; // ....
Optional<String> optionalWithValue = Optional.of("foo"); optionalWithValue.ifPresent(System.out::println);//Prints "foo". Optional<String> emptyOptional = Optional.empty(); emptyOptional.ifPresent(System.out::println);//Does nothing.
Introduction All modern web browsers, NodeJs as well as almost every other JavaScript environments support writing messages to a console using a suite of logging methods. The most common of these methods is console.log(). In a browser environment, the console.log() function is predominantly used f...
A normal function declaration looks like this: function foo(){ } A function defined like this is accessible from anywhere within its context by its name. But sometimes it can be useful to treat function references like object references. For example, you can assign an object to a variable based...

Page 16 of 826