Compile Assert in Java

Smita Kapse
Updated on 26-Jun-2020 06:50:33

684 Views

In order to compile assert in Java, we simply set the boolean expression as false.Let us see an example program −Example Live Demopublic class Example {    public static void main(String[] args) {       assert false;       System.out.println("Compiled and executed successfully!!!");    } }OutputCompiled and executed successfully!!!

Enable Assertions from the Command Line in Java

Anvi Jain
Updated on 26-Jun-2020 06:46:07

512 Views

By default, assertions are disabled in Java. In order to enable them we use the following command −java -ea Example (or) java -enableassertions ExampleHere, Example is the name of the Java file.Let us see an example for generation of an assertion error by the JVM −Example Live Demopublic class Example {    public static void main(String[] args) {       int age = 14;       assert age >= 18 : "Cannot Vote";       System.out.println("The voter's age is " + age);    } }OutputThe voter's age is 14

JSON Encoder and Decoder Package in Python

Chandu yadav
Updated on 26-Jun-2020 06:42:28

3K+ Views

JSON stands for JavaScript Object Notation. It is a lightweight data interchange format. It is similar to pickle. However, pickle serialization is Python specific whereas JSON format is implemented by many languages. The json module in Python’s standard library implements object serialization functionality that is similar to pickle and marshal modules.Just as in pickle module, the json module also provides dumps() and loads() function for serialization of Python object into JSON encoded string, and dump() and load() functions write and read serialized Python objects to/from file.dumps()This function converts the object into JSON format.loads()This function converts a JSON string back to ... Read More

Should I Use img, object, or embed for SVG Files?

Swarali Sree
Updated on 26-Jun-2020 06:36:09

461 Views

To add SVG files, you can use , or element in HTML. Choose any one of them according to your requirement. Here’s how you can add SVG, elementUse the tag for images without interaction.The disadvantage is you cannot manipulate images with JavaScript. elementThe element is used to define an embedded object within an HTML document. Use it to embed multimedia like audio, video, flash, etc in the web page.    Your browser does not support SVG elementThe tag wasn’t part of the HTML 4 specification and is new in HTML5. It validates in an HTML5 page.

Use SVG Files in a Webpage

Swarali Sree
Updated on 26-Jun-2020 06:33:18

716 Views

The svg files are Scalable Vector Graphics. You can add it to a web page using the , , or tag.The .svg file is to be referenced in the src attribute of the tag. Let’s see how to add it using the tag.You can try to run the following code to learn how to use .svg files in a web page. We have a smiley.svg file −           HTML SVG               Design          

Python Getpass Module

Arjun Thakur
Updated on 26-Jun-2020 06:31:13

1K+ Views

There are two functions defined in getpass module of Python’s standard library. They are useful whenever a terminal based application needs to be executed only after validating user credentials.getpass()This function prompts the user to enter a password. By default the keys entered by user in the terminal are not echoed. Also the default prompt that appears on terminal is ‘password’ which can be customized by providing a string as parameter.In following example, Python prompt is invoked from Command prompt terminal on Windows. The password entered is not echoed in the terminal.C:\python36>python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 ... Read More

Convert Float to String in Java

Samual Sam
Updated on 26-Jun-2020 06:30:12

307 Views

The valueOf() method is used in Java to convert float to string.Let’s say we have the following float value.float val = 10.18465F;Converting the above float value to string.String.valueOf(val);Example Live Demopublic class Demo {    public static void main(String[] args) {       float val = 98.18465F;       // converting float to String       String str = String.valueOf(val);       System.out.println("String: "+str);    } }OutputString: 98.18465

Add Scalable Vector Graphics (SVG) to Your Web Page

Samual Sam
Updated on 26-Jun-2020 06:30:10

251 Views

SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer. Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG.Note: If you already have an SVG file, then add it using , or tags.To add SVG to web page, use element. Through this, you can easily embed SVG in HTML5 −You can try to run the following code to add scalable vector graphics (SVG) to the web page:       ... Read More

Support for Line-Oriented Command Interpreters in Python

Ankith Reddy
Updated on 26-Jun-2020 06:29:29

470 Views

The cmd module contains only one class called Cmd. This is used as base class for a user defined framework for line oriented command line interpreters.CmdAn object of this class or its subclass provides the line oriented interpreter framework. Important methods of this class inherited by the subclass are listed below.cmdloop()This method sends the object in a loop, accepts inputs and sends the same to appropriate command handler method in the class.As the loop starts an introductory message (give as parameter to cmdloop() method) will be displayed with a default (cmd) prompt which may be customized by prompt attribute.The interpreter ... Read More

Convert Hexadecimal to Decimal

Ankith Reddy
Updated on 26-Jun-2020 06:29:13

17K+ Views

Whereas Hexadecimal number is one of the number systems which has value is 16 and it has only 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and A, B, C, D, E, F. Where A, B, C, D, E and F are single bit representations of decimal value 10, 11, 12, 13, 14 and 15 respectively. Whereas Decimal system is most familiar number system to the general public. It is base 10 which has only 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.Conversion from Hexadecimal to Decimal number systemThere are various ... Read More

Advertisements