A state
can be composite (State can hold multiple other states).
compositeState.txt@startuml
state compositeState1 {
state subState1 {
state s1
state s2
}
state subState2
}
state… Read More
Blog Directory > Software Blogs > java tutorial : Blog to learn java programming software Blog >
Java Tutorial : Blog To Learn Java Programming Blog
1
Tags:
Tutorial on Java, Design Patterns, collections, Struts, jdbc
Signaturehex(n)hive> SELECT * FROM emp;OKemp.id emp.name emp.hobbies emp.technology_experience emp.gender_age emp.rating1 Hari ["Football","Cricket"] {"Java":"3.4Yrs","C":"4.5Yrs"} {"gend… Read More
Signatureexp(n)hive> SELECT * FROM emp;OKemp.id emp.name emp.hobbies emp.technology_experience emp.gender_age emp.rating1 Hari ["Football","Cricket"] {"Java":"3.4Yrs","C":"4.5Yrs"} {"gend… Read More
Signaturecos(n)hive> SELECT * FROM emp;OKemp.id emp.name emp.hobbies emp.technology_experience emp.gender_age emp.rating1 Hari ["Football","Cricket"] {"Java":"3.4Yrs","C":"4.5Yrs"} {"gend… Read More
Signatureconv( bigint n, int from_base, int to_base )hive> SELECT * FROM emp;OKemp.id emp.name emp.hobbies emp.technology_experience emp.gender_age emp.rating1 Hari ["Football","Cricket"]… Read More
Signatureceil(n)ceiling(n) 'ceil' function return the smallest integer value that is greater than or equal to this number.hive> SELECT * FROM emp;OKemp.id emp.name emp.hobbies emp.te… Read More
Signaturebin(n)hive> SELECT * FROM emp;OKemp.id emp.name emp.hobbies emp.technology_experience emp.gender_age emp.rating1 Hari ["Football","Cricket"] {"Java":"3.4Yrs","C":"4.5Yrs"} {"gend… Read More
java.util.Date ‘java.util.Date’ class is used to represent a specific instant in time, with millisecond precision since the 1st of January 1970 00:00:00 GMT (the epoch time). &nb… Read More
In this post, I am going to explain about the assert statement in Java with the help of examples. Assertions were added in Java1.4, that enables you to test the assumptions about your… Read More
AtlasClientV2#getGlossaryByGuid method is used to get the glossary by guid. Signaturepublic AtlasGlossary getGlossaryByGuid(String glossaryGuid) throws AtlasServiceException… Read More
Signature degrees(n)hive> SELECT degrees(90);OK_c05156.620156177409Time taken: 0.05 seconds, Fetched: 1 row(s) Previous … Read More
By supplying Direction.OUT argument to the edges method, we can get all the outgoing edges of a vertex. public Iterator edges(final Direction direction, final String... edgeLabels); G… Read More
Step 1: Install mysqlbrew install mysql $brew install mysqlUpdating Homebrew...==> Downloading https://homebrew.bintray.com/bottles/protobuf-3.13.0.catalina.bottle.tar.gz==> Downl… Read More
ArangoCollection interface provides 'drop' method to drop a collection. void drop() throws ArangoDBException; Drop a collection. void drop(boolean isSystem) throws ArangoDBExce… Read More
ArangoDatabase interface provides 'collection' method which takes a collection name as argument and return ArangoCollection. ExampleArangoCollection arangoCollection = arangoDatabase… Read More
SyntaxINSERT document INTO collectionName Example INSERT { "id" : 1, "firstName" : "Krishna", "lastName" : "Gurram"} INTO users Above sni… Read More
In upcoming posts, I am going to explain how to execute AQL queries using Arango Web UI. Let’s create a collection ‘users’ using ArangoDB web ui. Step 1: Logi… Read More
SyntaxFOR doc IN array_of_documents INSERT doc INTO colleciton_name Example let users_info = [ {"id": 2, "firstName" : "Sowmya", "lastName" : "Gurram"}, {… Read More
TestInfo class is used to inject information about the current test or container into a @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, @BeforeEach, @AfterEach, @BeforeAll, and… Read More
If a method parameter in a @RepeatedTest, @BeforeEach, or @AfterEach method is of type RepetitionInfo, the RepetitionInfoParameterResolver will supply an instance of RepetitionInfo. Repetiti… Read More
If a constructor or method parameter is of type TestReporter, the TestReporterParameterResolver will supply an instance of TestReporter. The TestReporter can be used to publish additional da… Read More
If you annotate @Email annotation on top of CharSequence, then the CharSequence should be a well-formed email address. Example @Email public String emailId; What are the suppor… Read More
If you add @Digits annotation on any number, then the number must be within accepted range. Example @Digits(integer = 9, fraction = 2) private double salary;… Read More
If you annotate any number with @DecimalMin annotation, then the number must be higher or equal to the specified minimum. Example @DecimalMin(value = "500") p… Read More
If you apply @DecimalMax annotation on a number, then the number must be lower or equal to the specified maximum. Example @DecimalMax(value = "100000") privat… Read More
If you annotate any element with @AssertFalse annotation, then the annotated element must be false. Example @AssertFalse private boolean isExperienced; Supported Types a. … Read More
'javax.validation.constraints' package provides number of annotations to do validations on data. Below table summarizes the annotations provided by JSR-380 sp… Read More
I am going to use Hibernate validator '6.0.10.Final'. dependency>groupId>org.hibernategroupId>artifactId>hibernate-validatorartifactId>version>6.0.10.Finalversion>depen… Read More
In this post, I am going to show you an example of bean validation API annotations @Min, @Size. JSR 380 specification provides @Min, @Size annotation to validate the bean properties… Read More
ProvideSystemProperty rule is used to set an arbitrary value to given system property. After the test the original value is restored. Example@Rulepublic final ProvideSystemProperty CO… Read More
JavaFX JavaFX BasicsJavaFX is a high performance graphical user interface library provided by java. It is used to build platform independent, rich UI client applications. Read more… Read More
TableView class is used to define a table view control. TableView represent the data in rows and columns. Is TableView scrollable? Yes Is TableView editable? Yes TableCo… Read More
We can convert the output of range() function to a list using ‘list()’ function. Example list(range(1, 10))>>> list1 = list(range(1, 10))>>> >>>… Read More
‘min()’ function takes a list as argument and return minimum element from list of elements. Get minimum number from list of numbers>>> list1 = [2, 4, 1, -9, 89, … Read More
ListView displays a horizontal or vertical list of items from which the user may select, or with which the user may interact. A ListView is able to have its generic… Read More
ToolBar control is used to display items horizontally or vertically. Example ToolBar toolBar = new ToolBar(); toolBar.getItems().addAll(copyButton, cutButton, pastButton, undoButton… Read More
MenuItem MenuItem is intended to be used in conjunction with Menu to provide options to users. Following are the sub classes of MenuItem. a. CheckMenuItem b. ContextM… Read More
Hyperlink widget is used to create hyper link controls. Hyperlink can be a graphic and/or text which responds to rollovers and clicks. Hyperlinks are underlined, whe… Read More
TextField class is used to create a TextField widget. Can a TextField has support to multi line input? No, TextField support single line input. If you want multi line support, you sho… Read More
BorderPane lays out children in top, left, right, bottom, and center positions. a. The top and bottom children will be resized to their preferred heights and extend the wi… Read More
AnchorPane allows the edges of child nodes to be anchored to an offset from the anchor pane's edges. If the anchor pane has a border and/or padding set, the offsets will be measured fr… Read More
StackPane layout place UI components in a single stack. The z-order of the children is defined by the order of the children list with the 0th child being the bottom and last child on top.&nb… Read More
Output of one effect can be set as input to other effect. Using this chaining, we can apply multiple effects to the node. In this post, I am going to apply reflection affect as input… Read More
This effect is used to provide 3D effect for 2D content by creating a perspective in Z-axis direction. A perspective transformation is capable of mapping an arbitrary quadrilateral in… Read More
SepiaTone class is used to produces a sepia tone effect, similar to antique photographs. ‘SepiaTone’ class provides following constructors to get an instance of SepiaTone… Read More
DisplacementMap effect shifts each pixel by a distance specified by the first two bands of of the specified FloatMap. What is FloatMap? FloatMap is a buffer t… Read More
Reflection effect renders a reflected version of the input below the actual input content. Reflection class provides following constructors to define Reflection instance. … Read More
ColorInput effect is used to render a rectangular region that is filled with the given color. ColorInput serves as an effect to other effect instance. house.png … Read More
The lighting effect simulates a light source shining on the given content, which can be used to give flat objects a more realistic three-dimensional appearance. Why… Read More
ColorAdjust effect is used to adjust the color of an image by adjusting hue, saturation, brightness, and contrast. Step 1: Get an instance of ColorAdjust. ColorAdjust colorAdjust = ne… Read More
Glow is a high-level effect that makes the input image appear to glow, based on a configurable threshold. Glow class provides following constructors to get an instance of Glow. … Read More
The bloom effect makes portions of an image appear to glow, based on a configurable threshold. Bloom class provides following constructors to define Bloom instance. public Bloom() pu… Read More
Step 1: Extend 'javafx.application.Application' class and override start method.public class HelloWorld extends Application {@Overridepublic void start(Stage primarySt… Read More
Why JavaFX? a. Rich Client Platform with lot of features to develop rich desktop clients. b. Rich UI controls like buttons, text boxes, check… Read More
Functions are first class citizens in Scala. ‘sum’ function takes two integer arguments and return the sum of two variables.scala> def sum(a: Int, b : Int) = a + bdef sum(a: I… Read More
Yes, a constructor can be private in Java.Possible Scenariosa. A class with all static methods.Suppose you define an utility class with all static methods, then there is no point of creating… Read More
Suppose you have comma separated values like below.supportedVersions=0.5,0.7,0.9You can populate a list from the property 'supportedVersions' using Spring EL (Expression Language).@Value("#{… Read More
Tags are used to group the APIs. Tags are created using ‘tags’ element.Examplepaths: /employees/{employeeId}: get: tags: - single - getdata.yamlopenapi: 3… Read More
Step 1: Create API definition fileemployees.yamlopenapi: 3.0.0info: title: Customer Data Aceess API description: API to expose all the CRUD operations on customers contact: name: Kris… Read More
Suppose you are given an Employee class, which overrides hashCode method. Now the question is ‘How will you get the original hash code of the object?’AnswerUse the method 'identi… Read More
Using ‘TRUNCATE’ command, you can delete all the rows from a table.Syntax: ::= TRUNCATE ( TABLE | COLUMNFAMILY )? Example:TRUNCATE keyspaceName.tableName;If you are already in th… Read More
You can delete a row from cassandra table using 'DELETE FROM' statement.Syntax:delete-stmt> ::= DELETE ( ( ',' )* )?FROM ( USING TIMESTAMP integer>)?WHERE where-cla… Read More
In this post, I am going to explain how to handle bidirectional relationships using Jackson @JsonManagedReference, @JsonBackReference annotations. Let’s take an example of simple one… Read More
Following snippet converts US_ASCII byte array to string.byte[] byteArr = {72,101,108,108,111,32,87,111,114,108,100};String str = new String(byteArr, StandardCharsets.US_ASCII); App.javapac… Read More
CQL support aliases in SELECT statement using AS keyword.Examplecqlsh> SELECT * FROM cassandratutorial.employee; id | age | firstname | lastname----+-----+-----------+---------- 1 | 3… Read More
The default value for a Boolean (or any object) field is null.The default value for a boolean (primitive) field is false.DemoClass.javapackage com.sample.app;public class DemoClass {boolea… Read More
‘DESCRIBE TABLE tableName’ or ‘DESC TABLE tableName’ gives you the information about a table.cqlsh> DESCRIBE KEYSPACES;system_schema system system_d… Read More
Approach 1: Using iteratorIterator> iterator = map.entrySet().iterator();while (iterator.hasNext()) { iterator.remove();} Read More
You can create a table using ‘CREATE TABLE’ command.SyntaxCREATE TABLE [IF NOT EXISTS] [keyspace_name.]table_name ( column_definition [, ...] PRIMARY KEY (column_name [, c… Read More
Below snippet prints generic type of a field.public static void printGenericType(Field field) { ParameterizedType genericType = (ParameterizedType) field.getGenericType();int lengthOfArgum… Read More
Below snippet prints generic type of a field.public static void printGenericType(Field field) { ParameterizedType genericType = (ParameterizedType) field.getGenericType();int lengthOfArgum… Read More
You can change the replication strategy of the keyspace using ‘ALTER KEYSPACE’ command. SyntaxALTER KEYSPACE keyspace_name WITH REPLICATION = { 'class' : 'SimpleStrate… Read More
Approach 1: DESCRIBE keyspaces;Approach 2: SELECT * FROM system_schema.keyspaces;cqlsh> DESCRIBE KEYSPACES;system_schema system_auth system system_distributed system_tracescqlsh>… Read More
Below snippet prints generic type of a field.public static void printGenericType(Field field) { ParameterizedType genericType = (ParameterizedType) field.getGenericType();int lengthOfArgum… Read More
Below snippet prints generic type of a field.public static void printGenericType(Field field) { ParameterizedType genericType = (ParameterizedType) field.getGenericType();int lengthOfArgum… Read More
Approach 1: Traversing to each element and convert.public static Integer[] getBoxedArray_approach1(int[] arr) {if (arr == null)return null; Integer[] result = new Integer[arr.length];int i… Read More
‘Arrays.sort’ function is used to sort array elements in descending order.ExampleInteger[] arr = { 1, 3, 5, 7, 2, 4, 6, 8, 10 };Arrays.sort(arr, Collections.reverseOrder());App… Read More
Following statement sorts the array in ascending order.Arrays.sort(arr);App.javapackage com.sample.app;import java.io.IOException;import java.util.Arrays;public class App {private static v… Read More
Approach 1: Using ScannerString content = new Scanner(new File(filePath)).useDelimiter("\\Z").next();Approach 2: Using Files.readAllBytes.String content = new String(Files.readAllBytes(Paths… Read More
Below snippet return all the employees whose name contains given string.// SELECT * FROM employee WHERE firstName LIKE %:nameStartWith%public List findByFirstNameContaining(String str);Find… Read More
Following query method return all the employees whose firstName starts with given string.// SELECT * FROM employee WHERE firstName LIKE :nameStartWith%public List findByFirstNameStartingWith… Read More
Following method return all the employee details whose firstName ends with given string.// SELECT * FROM employee WHERE firstName LIKE %:nameEndWithpublic List findByFirstNameEndingWith(St… Read More
You can customize the json response payload properties using '@JsonProperty' annotation.Examplepublic class Employee {@JsonProperty("employee_id")private int id;@JsonProperty("first_name")… Read More
@JsonPropertyOrder annotation is used to specify the order of entity properties while serializing.Example@JsonPropertyOrder({"last_name", "first_name", "employee_id"})public class Employee… Read More
‘@RequestBody’ annotation maps request payload to given objectIn the bleow example, @RequestBody annotation maps request payload to Employee object.@RequestMapping(value… Read More
Just add below dependency to your application. com.fasterxml.jackson.dataformat jackson-data… Read More
Below snippet creates simple REST endpoint to home page.@RestControllerpublic class HomeController { @RequestMapping("/") public String home() { &n… Read More
Spring boot has default support for JSON payload. For example, below snippet return all the employees data in json format.@RequestMapping(value = "employees", method = RequestMethod.GET)pu… Read More
Previous &n… Read More
This is continuation to my previous post. You can download previous working application from this link.Step 1: Create interceptor class. PerformanceReportInterceptor.javapackage com.sample… Read More
This is continuation to my previous post. In my previous post, I explained how to test service layer.You can download previous working application from this link.In this post, I am going t… Read More
This is continuation to my previous post. You can download previous working application from this link.Step 1: Create ‘webapp’ folder under src/main of maven project.Right clic… Read More
In my previous post, I explained how to write unit tests. In this post, I am going to explain how to write integration tests to service layer.This is continuation to my previous post, You… Read More
This is continuation to my previous post, you can download previous application from below github link.Spring boot comes with default configurations.For example, when I add ‘spring-b… Read More
Any non-trivial application runs at least in three different environments.a. Developmentb. Testingc. ProductionDepend on the type of environment… Read More
In my previous post, I explained simple REST application. You can download previous working application from this link.Areas of improvementa. We are not done any validations wh… Read More
This is continuation to my previous post. In this post, I am going to explain how to add rest end points to the previous application.You can download the previous working application from… Read More
'debug' is a tiny JavaScript debugging utility.Install debug packageStep 1: Create a folder ‘debugDemo’Step 2: Go inside ‘debugDemo’ folder and execute the command… Read More
In this post, I am going to show you how to debug a node.js application using chrome development tools.Create a node.js application like below.HelloWorld.js//Load express moduleconst expre… Read More
Introduction to body-parser Express: body-parser: hello World applicationPrevious … Read More