Rules for Private Methods in an Interface in Java 9

raja
Updated on 21-Feb-2020 12:43:46

1K+ Views

Java 9 added a new feature of private methods to an interface. The private methods can be defined using a private modifier. We can add both private and private static methods in an interface from Java 9 onwards.Rules for private methods in an interface:A private method has a body in an interface means that we can’t be declared as a normal abstract method as usually do in an interface. If we are trying to declare a private method without a body then it can throw an error says that "This method requires a body instead of a semicolon".We can't be used both private and abstract modifiers together in an interface.If ... Read More

Force Chrome's Script Debugger to Reload JavaScript

Govinda Sai
Updated on 21-Feb-2020 12:43:45

4K+ Views

To force Google Chrome’s script debugger to reload JavaScript, follow the below steps −Open Dev ToolsClick on the Sources tabFind your script / image / fileCheck the right panel to see if your file is up to dateIf the file is not up to date, then −Right-click the resource in the left panel and choose 'Open Link in New Tab'Force a reload of the resource with CTRL+F5

Best Tools to Debug JavaScript and jQuery Code

Daniol Thomas
Updated on 21-Feb-2020 12:42:05

194 Views

The following are some of the best browser-based debugging tools for JavaScript −FireBugFireBug is a Firefox addon, widely used to inspect the code. Edit, debug and monitor CSS, HTML, and JavaScript live in any web page.Credit− FirebugDragonFlyDragonFly is a fully-featured suite of developer tools. It supports cross-device and remote debugging, which makes the work of developers easy.Credit − DragonFly

Find Sum of a List of Numbers in Python

Jayashree
Updated on 21-Feb-2020 12:30:30

175 Views

Python's built-in function sum() returns sum of numbers in an iterable object such as list or tuple. It takes two arguments, initial value which is optional and 0 by default and iterable objectExample>>> l1=[10,20,30,40,50] >>> ttl=sum(l1) >>> ttl 150 >>> ttl=sum(range(10)) >>> ttl 45

Find the Greatest Number in a List of Numbers in Python

Jayashree
Updated on 21-Feb-2020 12:27:17

256 Views

Python's built-in library function max() returns the largest number in an iterable or commaa separated list of numbers.>>> max(10,23,43,21) 43 >>> l1=[4,7,2,9,1] >>> max(l1) 9

Generate Armstrong Numbers in Python

Jayashree
Updated on 21-Feb-2020 12:26:50

2K+ Views

Any three digit number is called an Armstrong number of sum of cube of its digits equals the number itself. In order to check if a number satisfies this condition, each digit from it is successively separated from right and its cube is cumulatively added. In the end if the sum is found to be equal to original number, it is called Armstrong number.ExampleFollowing Python code prints all armstrong numbers between 100 to 999for num in range(100, 1000):   temp=num   sum=0   while temp>0:     digit=temp%10     sum=sum+digit**3     temp=temp//10   if sum==num:     ... Read More

Print Fibonacci Sequence Using Python

Jayashree
Updated on 21-Feb-2020 12:25:51

757 Views

Fibonacci series contains numbers where each number is sum of previous two numbers. This type of series is generated using looping statement.Examplex=0 y=1 fibo=0 while fibo

New Methods Added to Optional Class in Java 9

raja
Updated on 21-Feb-2020 12:21:47

320 Views

An Optional class provides a container that may or may not contain a non-null value. This Optional class introduced in Java 8 to reduce the number of places in the code where a NullPointerException can be generated. Java 9 added three new methods to Optional class: or(), ifPresentOrElse() and stream() that help us to deal with default values.Optional.or()The or() method introduced in Java 9 and the parameter of this method is a functional interface Supplier. This method always gives us an Optional object that is not empty. If the Optional object is not empty, it returns the Optional object itself. Otherwise, it returns an Optional ... Read More

MySQL Generated Columns with Mathematical Expressions

Samual Sam
Updated on 21-Feb-2020 12:20:32

176 Views

It can be illustrated with the help of an example in which we are creating a stored generated column in the table named ‘triangle_stored’. As we know that stored generated column can be generated by using the keyword ‘stored’.Examplemysql> Create table triangle_stored(SideA DOUBLE, SideB DOUBLE, SideC DOUBLE AS (SQRT(SideA * SideB + SideB * SideB)) STORED); Query OK, 0 rows affected (0.47 sec) mysql> Describe triangle_stored; +-------+--------+------+-----+---------+------------------+ | Field | Type   | Null | Key | Default | Extra            | +-------+--------+------+-----+---------+------------------+ | SideA | double | YES  |     | NULL   ... Read More

New Features Added to Stream API in Java 9

raja
Updated on 21-Feb-2020 12:20:30

209 Views

In Java 9, Oracle Corporation has added four useful new methods to Stream API. Those methods are iterate(), ofNullable(), takeWhile() and dropWhile().iterate()The iterate() can be used as stream version replacement of traditional for-loops. This method has improved by adding another parameter, the Predicate interface that allows us to stop these endless numbers based on conditions defined with the Predicate interface.Exampleimport java.util.stream.Stream; public class StreamIterateMethodTest {    public static void main(String[] args) {       Stream.iterate(1, i -> i < 5, i -> i + 1).forEach(System.out::println); // iterate()    } }Output1 2 3 4ofNullable()The ofNullable() method returns the stream object of an element if it ... Read More

Advertisements