Skip to main content


Showing posts from July, 2020


@RestController Basically, in web-based applications, a client communicates with the server using its API, i.e. various methods available from outside via HTTP (HyperText Transport Protocol) requests. A controller is a part of the application that handles these API methods.The @RestController annotation is usually on top of the class. It declares that a class will provide the exact endpoints (URLs you request for) to access the REST methods. The class itself and its methods can tell which requests are suitable. All the appropriate requests will be sent to the concrete method of this class.Now we'll explore how to work with the two most popular methods: POST and GET as well as corresponding annotations, @PostMapping and @GetMapping. @PostMapping You can place this one before the method of a @RestController class. The method will provide the POST request handling. With this REST method, we can send some information to the request body. Usually, the method saves this information on the …


Resizable arrays One of the most widely used classes of Java Class Library is a class named ArrayList that represents a resizable array of objects of a specified type. Unlike the standard array denoted as [], it can dynamically grow after the addition and shrink after the removal of its elements. This behavior is very useful if you do not know the size of the array in advance or you need one that can change sizes over the lifetime of a program.In fact, this class is built on top of a standard Java array, extending it with a set of convenient operations. Like a standard array, it allows getting the current number of elements (its size) as well as accessing its elements by their indexes.There is only one restriction: ArrayList: being a generic class, it cannot store primitive types. However, it can store any reference types, including String's, wrapper classes (like Integer's), other ArrayList's, and custom classes. Creating an instance of ArrayList To start using the class by …

What is JSON

JSON (or JavaScript Object Notation) is a text-based format for storing and transmitting structured data. It comes from the JavaScript language, but it is still considered to be language-independent: it works with almost any programming language. With JSON's lightweight syntax, you can easily store and send to other apps everything from numbers and strings to arrays and objects. You can also create more complex data structures by linking arrays to each other. Basic syntax and structure JSON text can be built on one of two structures:a collection of key:value pairs (associative array);an orderly set of values (array or list).JSON objects are written in curly braces {}, and their key:value pairs are separated by a comma ,. The key and the value in the pair are separated by a colon :. Here is an example for you:{
"first_name": "Sophie",
"last_name": "Goodwin",
"age": 34
Here you can see some user's data in JSON format.Keys in an object…