Tutorial by Examples: sin

Comparator.comparing(Person::getName) This creates a comparator for the class Person that uses this person name as the comparison source. Also it is possible to use method version to compare long, int and double. For example: Comparator.comparingInt(Person::getAge) Reversed order To create ...
Starting with Java 8, you can use lambda expressions & predicates. Example: Use a lambda expressions & a predicate to get a certain value from a list. In this example every person will be printed out with the fact if they are 18 and older or not. Person Class: public class Person { p...
An anonymous inner class is a form of inner class that is declared and instantiated with a single statement. As a consequence, there is no name for the class that can be used elsewhere in the program; i.e. it is anonymous. Anonymous classes are typically used in situations where you need to be abl...
Using parameters passed by reference An event may define a ByRef parameter meant to be returned to the caller: Public Event BeforeSomething(ByRef cancel As Boolean) Public Event AfterSomething() Public Sub DoSomething() Dim cancel As Boolean RaiseEvent BeforeSomething(cancel) If...
Perl interpolates variable names: my $name = 'Paul'; print "Hello, $name!\n"; # Hello, Paul! my @char = ('a', 'b', 'c'); print "$char[1]\n"; # b my %map = (a => 125, b => 1080, c => 11); print "$map{a}\n"; # 125 Arrays may be interpolated as a whol...
First, define a used defined table type to use: CREATE TYPE names as TABLE ( FirstName varchar(10), LastName varchar(10) ) GO Create the stored procedure: CREATE PROCEDURE prInsertNames ( @Names dbo.Names READONLY -- Note: You must specify the READONLY ) AS INSERT INTO d...
For expressing the power of 2 (2^n) of integers, one may use a bitshift operation that allows to explicitly specify the n. The syntax is basically: int pow2 = 1<<n; Examples: int twoExp4 = 1<<4; //2^4 int twoExp5 = 1<<5; //2^5 int twoExp6 = 1<<6; //2^6 ... int twoEx...
The "right-left" rule is a completely regular rule for deciphering C declarations. It can also be useful in creating them. Read the symbols as you encounter them in the declaration... * as "pointer to" - always on the left side [] as "array of" ...
To use SQL syntax with model, that would transfer result to proper instantions, you should use directly one of Phalcon\Mvc\Model\Resultset classes: $users = new \Application\Models\Users(); // bitwise operation on `flag` field $sql = 'SELECT * FROM phorum.users WHERE (15 & (1 <&...
This example shows the base of almost any XSLT transformation and the most fundamental XSLT design pattern. Producing as output an XML document that is identical to the source XML document. Source XML document: <t>Hello, World!</t> XSLT transformation: <xsl:stylesheet version=&q...
A downcast can be used to make use of a subclass's code and data inside of a function taking a parameter of its superclass. class Rat { var color = "white" } class PetRat: Rat { var name = "Spot" } func nameOfRat(🐭: Rat) -> String { guard let petRat = ...
In the following code let us assume for simplicity that float and uint32_t have the same size. void fun(uint32_t* u, float* f) { float a = *f *u = 22; float b = *f; print("%g should equal %g\n", a, b); } u and f have different base type, and thus the compiler can a...
A common use of macros is to create templates for data structures which obey common rules but may contain different fields. By writing a macro, you can allow the detailed configuration of the data structure to be specified without needing to repeat boilerplate code, nor to use a less efficient struc...
The FileSystem API of Java 7 allows to read and add entries from or to a Zip file using the Java NIO file API in the same way as operating on any other filesystem. The FileSystem is a resource that should be properly closed after use, therefore the try-with-resources block should be used. Reading ...
Description This is a self-contained running example including/showcasing: minimum dependencies needed, Java Configuration, Bean declaration by annotation and Java Configuration, Dependency Injection by Constructor and by Property, and Pre/Post hooks. Dependencies These dependencies are needed in...
The exposition pipe operator, %$%, exposes the column names as R symbols within the left-hand side object to the right-hand side expression. This operator is handy when piping into functions that do not have a data argument (unlike, say, lm) and that don't take a data.frame and column names as arg...
Python's built-in crypto functionality is currently limited to hashing. Encryption requires a third-party module like pycrypto. For example, it provides the AES algorithm which is considered state of the art for symmetric encryption. The following code will encrypt a given message using a passphrase...
This code adds outwardly increasing shadows to an image to create a "sticker" version of the image. Notes: In addition to being an ImageObject, the "img" argument can also be a Canvas element. This allows you to stickerize your own custom drawings. If you draw text on the Can...
First, in addition to the normal Fresco Gradle dependency, you have to add the OkHttp 3 dependency to your build.gradle: compile "com.facebook.fresco:imagepipeline-okhttp3:1.2.0" // Or a newer version. When you initialize Fresco (usually in your custom Application implementation), you ...

Page 89 of 161