-
Using new keyword → constructor get called Employee emp1 = new Employee();
-
Using newInstance() method of Class → constructor get called Employee emp2 = (Employee) Class.forName("org.programming.mitra.exercises.Employee").newInstance(); It can also be written as Employee emp2 = Employee.class.newInstance();
OAuth is a standard that applications (and the developers who love them) can use to provide client applications with “secure delegated access”. OAuth works over HTTP and authorizes Devices, APIs, Servers and Applications with access tokens rather than credentials, which we will go over in depth below. | |
There are two versions of OAuth: OAuth 1.0a and OAuth2. These specifications are completely different from one another, and cannot be used together: there is no backwards compatibility between them. | |
Which one is more popular? Great question! Nowadays (at this time of writing), OAuth2 is no doubt the most widely used form of OAuth. So from now on, whenever I write just “OAuth”, I’m actually talking about OAuth2 — as it is most likely what you’ll be using. |
var Types = new Map(); | |
Types.set(Array, function(v) { | |
var l = v.length; i = 0, a = Array(l); | |
for (i; i<l; i++) { | |
a[i] = v[i]; | |
} | |
return a; | |
}); | |
Types.set(Number, function(v) { | |
return v * 1; |
var users = [ | |
{ 'user': 'fred', 'age': 48 }, | |
{ 'user': 'barney', 'age': 36 }, | |
{ 'user': 'fred', 'age': 40 }, | |
{ 'user': 'barney', 'age': 34 } | |
]; | |
_.sortBy(users, [function(o) { return o.user; }]); | |
// => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] | |
Sample code on how @Mock and @InjectMocks works. | |
Say we have Game and Player class. | |
class Game { | |
private Player player; | |
public Game(Player player) { | |
this.player = player; |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Bootstrap Example</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> |
This annotation eliminates the need of annotating each method with @ResponseBody. Under the hood, @RestController is itself annotated with @ResponseBody, and can be considered as combination of @Controller and @ResponseBody.
If a method parameter is annotated with @RequestBody, Spring will bind the incoming HTTP request body(for the URL mentioned in @RequestMapping for that method) to that parameter. While doing that, Spring will [behind the scenes]
Collection framework is a set of classes and interfaces. It is referred as a collection, but it is used as a library for resusable collection data structures. Both arrays and collections function similarly as they both hold references to the objects and work as a group but the primary difference is that collections do not need to be assigned capacity when they are instantiated as collections can grow and shrink automatically as object are added or removed.
There are basically three types of collection: sets, lists and maps.
// For GET request | |
if (marks != null && roll != null && !roll.isEmpty()) { | |
RestTemplate restTemplate = new RestTemplate(); | |
String url = PropsUtil.get("some.server") + "/mark/v1/" + roll; | |
ResponseEntity<String> result = restTemplate.getForEntity(url, String.class); | |
String data = result.getBody(); | |
if (data != null) { | |
JSONObject json = JSONFactoryUtil.createJSONObject(data); |
pushd "%~dp0" | |
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt | |
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i" | |
del hyper-v.txt | |
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL | |
pause |