Comparison of Float in Java

karthikeya Boyini
Updated on 26-Jun-2020 12:34:33

334 Views

To compare Float in Java, use the following methods −Method 1 − compareTo(newFloat) method in JavaThe java.lang.Float.compareTo() method compares two Float objects. This method returns the value 0 if the new float value is numerically equal to this Float; a value less than 0 if this Float is numerically less than new float; and a value greater than 0 if this Float is numerically greater than new float.Here is an example −Example Live Demoimport java.lang.*; public class Demo {    public static void main(String args[]) {       Float f1 = new Float("25.2");       Float f2 = new ... Read More

Page Rank Algorithm and Implementation Using Python

karthikeya Boyini
Updated on 26-Jun-2020 12:32:55

5K+ Views

The PageRank algorithm is applicable in web pages. Web page is a directed graph, we know that the two components of Directed graphsare -nodes and connections. The pages are nodes and hyperlinks are the connections, the connection between two nodes.We can find out the importance of each page by the PageRank and it is accurate. The value of the PageRank is the probability will be between 0 and 1.The PageRank value of individual node in a graph depends on the PageRank value of all the nodes which connect to it and those nodes are cyclically connected to the nodes whose ... Read More

MySQL Foreign Key Checks and Their Impact on the Database

Arjun Thakur
Updated on 26-Jun-2020 12:32:00

5K+ Views

The foreign_key_checks are session based. Now, we can say that they are for scope i.e. local or global. Here is an example demo of local or global. Both are scopes and we can set this for session.Let us set the scope −mysql> set foreign_key_checks = 0; Query OK, 0 rows affected (0.00 sec) mysql> set global foreign_key_checks = 0; Query OK, 0 rows affected (0.05 sec)The foreign_key_checks variables are server system variables. Here are some more details −PropertyValueSystem Variableforeign_key_checksScopeGlobal, SessionDynamicYesTypeBooleanDefault ValueONSetting foreign_key_checks to 0It affects data definition statements: DROP SCHEMA drops a schema even if it contains tables that have ... Read More

Different Methods to Find Prime Number in Python

Samual Sam
Updated on 26-Jun-2020 12:31:53

1K+ Views

First we need to know what a prime number is.A prime number always a positive integer number and divisible by exactly 2 integers (1 and the number itself), 1 is not a prime number.Now we shall discuss some methods to find Prime Number.Method1Using For loopsExampledef primemethod1(number):    # Initialize a list    my_primes = []    for pr in range(2, number):       isPrime = True    for i in range(2, pr):    if pr % i == 0:       isPrime = False    if isPrime:       my_primes.append(pr)    print(my_primes) primemethod1(50)Output[2, 3, 5, 7, 11, ... Read More

Use UPDATE Query with LIMIT in MySQL

Chandu yadav
Updated on 26-Jun-2020 12:30:35

10K+ Views

Yes, it is possible to use UPDATE query with LIMIT in MySQL. Let us see how.For our example, we will first create a table. The CREATE command is used to create a table.mysql>CREATE table tblUpdateLimit -> ( -> id int, -> name varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)Records are inserted with the help of INSERT command.mysql>INSERT into tblUpdateLimit values(1, 'John'); Query OK, 1 row affected (0.54 sec) mysql>INSERT into tblUpdateLimit values(2, 'Carol'); Query OK, 1 row affected (0.12 sec) mysql>INSERT into tblUpdateLimit values(3, 'Smith'); Query OK, 1 row affected (0.10 sec) mysql>INSERT into ... Read More

Check Similarity Between Two Strings in MySQL

Arjun Thakur
Updated on 26-Jun-2020 12:27:33

2K+ Views

Similarity between two strings can be checked with the help of ‘strcmp()’ function. Here are the conditions.If both strings are equal, then it returns 0.If first string is less than the second string, it returns -1.If first string is greater than the second string, it returns 1.Here is an example.Case 1 − If both strings are equal.The following is the query.mysql > SELECT STRCMP("demo", "demo");The following is the output of the above query.+------------------------+ | STRCMP("demo", "demo") | +------------------------+ | 0 ... Read More

JSON Formatting in Python

Samual Sam
Updated on 26-Jun-2020 12:26:45

9K+ Views

The JSON (Java Script Object Notation) is light weight, well accepted data interchange format. Using JSON formatting techniques in Python, we can convert JSON strings to Python objects, and also convert Python Objects to JSON strings.To use these functionalities, we need to use the json module of Python. The json module comes with the Python standard library. So at first we have to import it first.import jsonConverting Python objects to JSON StringIn the json module, there are some methods like dump(), and dumps() to convert Python objects to JSON strings. The dump() method takes two arguments, the first one is ... Read More

Escape Single Quotes in MySQL

Chandu yadav
Updated on 26-Jun-2020 12:24:56

560 Views

We can escape single quotes with the help of the SELECT statement. For instance, when single quotes are encountered in a name, eg. “Carol’s”.Let us see the syntax.SELECT ‘SomeValue’;Here is an example that display how to include text with single quotes.mysql> SELECT 'Carol\'s Taylor.'; The following is the output.+-------------------+ | Carol's Taylor | +-------------------+ | Carol's Taylor | +-------------------+ 1 row in set (0.00 sec)

Which One is Better in MySQL: NULL or Empty String

Arjun Thakur
Updated on 26-Jun-2020 12:24:27

442 Views

The choice depends upon the database. In ORACLE database, an empty string is converted to NULL.In MySQL, the usage of an empty string is better as compared to NULL. It is easy to check for an empty string with some boundary conditions, while this cannot be done with NULL. To find NULL, we need to add an extra condition i.e. ‘IS NULL’We can check that the length of NULL is 0 while length of empty string is 1.To check the length of NULL.mysql>SELECT count(NULL);The following is the output of the above query.+-----------------+ | count(NULL) | +-----------------+ ... Read More

Fastest Way to Count Rows in MySQL Table

Ankith Reddy
Updated on 26-Jun-2020 12:23:37

1K+ Views

Let us first see an example to create a table, add records and display them. The CREATE command is used to create a table.mysql> CREATE table RowCountDemo -> ( -> ID int, -> Name varchar(100) > ); Query OK, 0 rows affected (0.95 sec)Records are inserted with the INSERT command.mysql>INSERT into RowCountDemo values(1, 'Larry'); Query OK, 1 row affected (0.15 sec) mysql>INSERT into RowCountDemo values(2, 'John'); Query OK, 1 row affected (0.13 sec) mysql>INSERT into RowCountDemo values(3, 'Bela'); Query OK, 1 row affected (0.15 sec) mysql>INSERT into RowCountDemo values(4, 'Jack'); Query OK, 1 row affected (0.11 sec) ... Read More

Advertisements