Tutorial by Examples

These Java issues can be very embarrassing, and sometimes remain undiscovered until run in production. Fallthrough behavior in switch statements is often useful; however, missing a “break” keyword when such behavior is not desired can lead to disastrous results. If you have forgotten to put a “break...
Every time a program opens a resource, such as a file or network connection, it is important to free the resource once you are done using it. Similar caution should be taken if any exception were to be thrown during operations on such resources. One could argue that the FileInputStream has a finaliz...
Java manages memory automatically. You are not required to free memory manually. An object's memory on the heap may be freed by a garbage collector when the object is no longer reachable by a live thread. However, you can prevent memory from being freed, by allowing objects to be reachable that are...
This example is about deliberately ignoring or "squashing" exceptions. Or to be more precise, it is about how to catch and handle an exception in a way that ignores it. However, before we describe how to do this, we should first point out that squashing exceptions is generally not the co...
This exception occurs when a collection is modified while iterating over it using methods other than those provided by the iterator object. For example, we have a list of hats and we want to remove all those that have ear flaps: List<IHat> hats = new ArrayList<>(); hats.add(new Ushanka...
pip is your friend when you need to install any package from the plethora of choices available at the python package index (PyPI). pip is already installed if you're using Python 2 >= 2.7.9 or Python 3 >= 3.4 downloaded from python.org. For computers running Linux or another *nix with a native...
ASP.NET Core introduces the concept of dependency injection into Views via the @inject directive via the following syntax : @inject <type> <name> Example Usage Adding this directive into your View will basically generate a property of the given type using the given name within your ...
The basic math operations are performed mainly on numbers or on vectors (lists of numbers). 1. Using single numbers We can simple enter the numbers concatenated with + for adding and - for subtracting: > 3 + 4.5 # [1] 7.5 > 3 + 4.5 + 2 # [1] 9.5 > 3 + 4.5 + 2 - 3.8 # [1] 5.7 >...
Hello, World in the interactive interpreter To print "Hello, World!" in the Prolog interpreter (here we are using swipl, the shell for SWI Prolog): $ swipl <...banner...> ?- write('Hello, World!'), nl. ?- is the system prompt: it indicates that the system is ready for the user...
Amp harnesses Promises [another name for Awaitables] and Generators for coroutine creation. require __DIR__ . '/vendor/autoload.php'; use Amp\Dns; // Try our system defined resolver or googles, whichever is fastest function queryStackOverflow($recordtype) { $requests = [ Dns\qu...
In vc.h @interface vc : UIViewController<UIWebViewDelegate> in vc.m - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ if (navigationType == UIWebViewNavigationTypeLinkClicked){...
AsyncTaskLoader is an abstract Loader that provides an AsyncTask to do the work. Here some basic implementation: final class BasicLoader extends AsyncTaskLoader<String> { public BasicLoader(Context context) { super(context); } @Override public String loadInBa...
Dependency on Guava can be added in your Java project by using any build system. Maven: <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>19.0</version> </dependency> Gradle: dependencies { comp...
For Each row As DataRow In FooDataTable.Rows Me.RowsToProcess.Add(row) Next Dim myOptions As ParallelOptions = New ParallelOptions() myOptions.MaxDegreeOfParallelism = environment.processorcount Parallel.ForEach(RowsToProcess, myOptions, Sub(currentRow, state) ...
In C++, a byte is the space occupied by a char object. The number of bits in a byte is given by CHAR_BIT, which is defined in climits and required to be at least 8. While most modern systems have 8-bit bytes, and POSIX requires CHAR_BIT to be exactly 8, there are some systems where CHAR_BIT is great...
There are two possible ways to pass a value type by reference: ref and out. The difference is that by passing it with ref the value must be initialized but not when passing it with out. Using out ensures that the variable has a value after the method call: public void ByRef(ref int value) { C...
It is not possible to directly use static_cast, const_cast, dynamic_cast and reinterpret_cast on std::shared_ptr to retrieve a pointer sharing ownership with the pointer being passed as argument. Instead, the functions std::static_pointer_cast, std::const_pointer_cast, std::dynamic_pointer_cast and ...
The tree command lists the contents of a specified directory in a tree-like format. If no directory is specified then, by default, the contents of the current directory are listed. Example Output: $ tree /tmp /tmp ├── 5037 ├── adb.log └── evince-20965    └── image.FPWTJY.png Use the tree ...
curl -XGET http://www.example.com:9200/myIndexName/_search?pretty=true&q=*:* This uses the Search API and will return all the entries under index myIndexName. Reference Link: Here
Suppose we have a json : { "total_count": 132, "page_size": 2, "page_index": 1, "twitter_posts": [ { "created_on": 1465935152, "tweet_id": 210462857140252672, "tweet": "Along with our ne...

Page 591 of 1336