My Articles:
Learn to serialize a complex python class (e.g. User) and write serialized JSON data in file by extending JSONEncoder and custom serialization method. In Python serialize complex object to JSON example, we have following User class. Here, birthdate of type datetime. If we don’t use the custom serialization, we will …
Learn to read a JSON file and append JSON data into a file in Python. 1. Steps for Appending to a JSON File In Python, appending JSON to a file consists of the following steps: Refer to the following articles to learn how to read JSON from a file and …
Learn to write JSON data into an existing file using json.dump() method. Also, learn to apply sorting and formatting to the JSON written into the file. For quick reference, below is the code which writes a JSON dictionary object to a “users.json” file. 1. json.dump() Method The json.dump() serializes a …
Learn to read JSON string in Python with the help of json.loads() method which converts a given JSON string into a Python object. For quick reference, below is the code which reads a JSON string into a Python object. 1. json.loads() Method The json.loads() deserializes a given JSON string into …
Learn to read a JSON file in Python with the help of json.load() method which reads the data into a Python object. For quick reference, below is the code which reads a JSON file to a Python object. 1. json.load() Method The json.load() deserializes a given JSON file from the …
Learn to use Python bcrypt module for hashing a plain text password into encrypted String. Also learn to match the supplied password with already stored encrypted password with bcrypt module. 1. Python bcrypt module Bcrypt algorithm was designed by Niels Provos and David Mazières, based on the Blowfish cipher. Bcrypt …
Learn to calculate the Hash of a file in Python, with examples. It is also called the file checksum or digest. A checksum hash is an encrypted sequence of characters obtained after applying certain algorithms and manipulations on user-provided content. Read More: File checksum in Java 1. Hash Algorithms Hash …
In Python, string.count() is used to count the occurrences of a character or a substring in the given input string. Program Output. 1. String count() Syntax The syntax of count() function is: 1.1. Arguments Only the substring is required parameter. Start index and end index are optional parameters. substring : …
In Python, the capitalize() method capitalizes a string i.e. upper case the very first letter in the given string and lowercases all other characters, if any. Except changing the case (upper/lower), capitalize() does not modify the content of the original string. 1. capitalize() Syntax The syntax of capitalize() is pretty …
HikariCP is a lightweight JDBC connection pool. Learn about various options for configuring the HikariCP with Spring boot JPA and hibernate.
Learn how to test the different parts of a Spring Boot web application. We will see some very quick examples (using Junit 5) and configurations for: For demo purposes, we have created a very simple Employee management application. It has a few CRUD API calls for creating, fetching and deleting …
In TypeScript, filter(testFunction) is a built-in function available for arrays that returns a new array of elements satisfying a given condition.
Log4j2 ConsoleAppender appends the log events generated by the application into the System.out or System.err. The default target is System.err. The console appender uses the log message pattern specified by the user in configuration using PatternLayout property. 1. Log4j2 ConsoleAppender Configuration Use and customize the below-given configuration snippets for configuring …
Java 15 released on 15th Sep’2020 following the 6th-month release cycle. Java 15 continues support for various preview features in previous JDK releases; and also introduced some new features. Let us learn about these new features in Java 15. 1. Sealed Classes and Interfaces (Preview) (JEP 360) Prior to Java …
EdDSA (Edwards-Curve Digital Signature Algorithm) [RFC 8032] is another additional digital signature scheme added in Java 15 thorough JEP 339. It does not replace the existing Elliptic Curve Digital Signature Algorithm (ECDSA) in JDK. EdDSA provides following parameter choices : Algorithm Name Description EdDSA Edwards-Curve signature algorithm as defined in …
In Java, by default, there is no restriction on a class which public interfaces it can impliment. Since Java 15, now a class or interface can be declared sealed class or sealed interface using the modifier sealed. It is a preview feature in Java 15. A sealed class or interface …
Java 8 Stream.findAny() returns an Optional describing any element of Stream if Stream is non-empty. It returns an empty Optional if the stream is empty.
Java Stream findFirst() returns an Optional describing the first element of stream if Stream is non-empty, or an empty Optional if the stream is empty.
The Java FileWriter class is for writing the text to the character-based files using a default buffer size. It uses character encoding default to the platform, if not provided otherwise. FileWriter is usually wrapped by higher-level Writer types, such as BufferedWriter or PrintWriter. FileWriter provides better performance and higher-level, more …
The Java InputStreamReader class is often used to read characters from files (or network connections) where the bytes represents text. In this Java tutorial, we will learn about InputStreamReader class, its creation and initialization, and its methods which help in reading the data from the source. 1. InputStreamReader class It …
Java StringReader represents a character stream whose source is a string. Use it to pass a string to a method that accepts a Reader Type.
Java FileReader class can be used to read data (stream of characters) from files. In this tutorial, we will learn about FileReader class, its constructors, methods and usages with the help of examples. 1. Introduction The FileReader class is: 2. Creating FileReader To use the FileReader in the application, we …
Learn to install Java on 64-bit Windows machines in this step-by-step guide. 1. Navigate to the Oracle Java Download Page Navigate to the Java download page for the latest Java release. Click on the link “JDK Download”. 2. Download the zip or Exe Package Here you have two choices: 2.1. …
Learn to print a Python List in different ways such as with/without square brackets or separator, curly braces, and custom formatting with examples.
Learn 4 ways to redirect print() output from a Python program or script to a file with examples, and when to use which method.
In Python, the print() function is used for displaying output on the screen. By default, print() method adds a new line character (\n) at the end of the printed output on the screen. That is why all print() statements display the output in a new line on the screen. While …
Python print() function prints the given string or object to the standard output. The standard output is the screen or to the text stream file. Example: Print an integer to Screen Program output. Syntax of print() Method The complete syntax of the print() function is: Method Parameters The print() method …
The Python input() function allows user inputs in the programs. The input() function reads a line from the input, converts into a string and returns it as method return value. The input() function, optionally, allows a prompt String as the method argument that is displayed to user while taking the …
The Python pass statement is used to execute an empty statement. We can use the pass statement when we do not want to execute any statement at a place in the code, but Python requires us to specify a statement to satisfy the Syntax rules. Python pass statement is different …
Python continue statement skips the rest of the code inside a loop for the current iteration in a Loop and jumps the program execution to the beginning of the enclosing loop. If the continue statement is inside a nested loop (one loop inside another loop), the continue statement skips only …
Python break statement is used to terminate the a loop which contains the break statement. When a break statement is executed inside a loop, the program execution jumps to immidiately next statement after the loop. If the break statement is inside a nested loop (one loop inside another loop), the …
Learn to execute Python statement(s) as long as a condition is True with the help of python while loop. 1. The while Loop A while loop executes a given set of statements in loop, as long as a given conditional expression is True. As soon as, the conditional expression becomes …
Learn about Python conditional statements if, elif, else statements, indentation rules and shorthand if statements with examples.
Python Sets are unordered collections of unique elements. Learn about Set datatype in Python, creating and modifying Sets and other useful Set operations available. 1. What is Set A Set in Python is: an unordered collection of unique hashable objects unindexed collection written with curly brackets or set() constructor Internally, …
A Dictionary in Python is a collection data type which is unordered, mutable and indexed. In Python, dictionaries are written with curly brackets { }, and store key-value pairs. Dictionary keys should be the immutable Python object, for example, number, string, or tuple. Keys are case sensitive. Duplicate keys are …
Python bin() method converts a given integer to it’s equivalent binary string. If the method parameter is some other object (not integer) then it has to __index__() method (with double underscores on the both sides) which must return an integer value for the object. The prefix 0b represents that a …
Python ascii() method is language inbuilt function and returns a string containing a printable representation of an object. ascii() escapes the non-ASCII characters in the string using \x, \u or \U escapes. 1. Syntax The syntax of the ascii() method is: Here the object is required method argument and it …
In this post, we will see a very simple Python program that displays “Hello, World!” on the screen. Similar to Hello World programs in other languages, this program is also used to illustrate the syntax of the Python language. It is assumed that you have installed Python runtime on your …
Read, understand, and practice these Python examples to better understand the Python language. These simple python programs will help us understand Python’s basic programming concepts. All the programs on this page are tested and should work on all platforms. 1. Python Program to Print Hello World A very simple Python …
1. Python Inbuilt Functions Python abs() Returns the absolute value of a integer, float; and magnitude of a complex number. Python any() function Checks if at least one element of the Iterable is True. Python all() Returns true when all the elements in the Iterable are True. 2. Python String …
Python all() function returns True if all the elements of an iterable are True. If any element in the iterable is False, all() returns False. all() can be thought of as logical AND operation on elements on iterable. All values are True, all() returns True. All values are False, all() …
Python any() function returns True if at least one element of an iterable is Truthy. If no element in iterable is True, any() returns False. any() can be thought of as logical OR operation on elements on iterable. All values are True, any() returns True. All values are False, any() …
Python abs() function returns the absolute value of the given integer, floating point or complex number. The precise term for absolute is “non-negative.”
Learn implicit and explicit data type conversions in python. Also learn various type functions used for type conversion and few examples of how to do the typecasting between various python data types. 1. Type Conversion The process, by which one data type is converted to another data type, is called …
Learn to write a simple Java program to add two integers and display their sum in the console. 1. Java example to add two integers In given Java exmple, we have three int type variables i.e. firstInteger, secondInteger and sum. We have assigned values to the first two integers, and …
Python for loop is used to iterate over a list or sequence. Follow these examples to iterate over a list, tuple, dictionary, and set using for-loop.
We may get this error (Could not find or load main class) while running the Java class (e.g. Hello world application) from the system console. We get this error because we are incorrectly trying to run the main() inside the class using java command. 1. Reason for error – could …
Learn to read from and write to the system console in Java using readLine(), readPassword(), reader() and printf() methods.
Learn to write your first “Hello World” program in Java. It is often used to verify that the Java runtime is setup correctly.
To learn Java or any other programming language, the only best way is to practice and practice more. The more you do the coding, the better you get as time passes. These listed Java examples cover some very basic Java fundamentals and present you few alternative solutions to any single …