Maruthi Krishna has Published 464 Articles

Why can't we use the "super" keyword is in a static method in java?

Maruthi Krishna

Maruthi Krishna

Updated on 28-Jul-2021 14:43:59

4K+ Views

A static method or, block belongs to the class and these will be loaded into the memory along with the class. You can invoke static methods without creating an object. (using the class name as reference).Where the "super" keyword in Java is used as a reference to the object of ... Read More

How to create a Dialog in JavaFX?

Maruthi Krishna

Maruthi Krishna

Updated on 04-Jun-2021 06:10:21

11K+ Views

A Dialog is a graphical element, a window that shows information to the window and receives a response. You can create a dialog by instantiating the javafx.scene.control.Dialog class.ExampleThe following Example demonstrates the creation of a Dialog.import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ButtonType; import ... Read More

How to host a web-service using IIS (windows) and .net

Maruthi Krishna

Maruthi Krishna

Updated on 12-Feb-2021 11:11:22

6K+ Views

A web service is any piece of software which offers service to other systems. It makes itself available over the internet and uses a standardized XML or, JSON messaging system. A web service enables communication among various applications by using open standards such as HTML, XML, WSDL, and SOAP.IISIIS stands ... Read More

Can we override default methods in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 12:42:05

8K+ Views

An interface in Java is similar to class but, it contains only abstract methods and fields which are final and static.Since Java8 static methods and default methods are introduced in interfaces. Unlike other abstract methods these are the methods can have a default implementation. If you have default method in ... Read More

How to convert a super class variable into a sub class type in Java

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 11:52:56

11K+ Views

Inheritance is a relation between two classes where one class inherits the properties of the other class. This relation can be defined using the extends keyword as −public class A extends B{}The class which inherits the properties is known as sub class or, child class and the class whose properties are ... Read More

How to convert a double value into a Java String using append method?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 11:36:26

328 Views

The append method of the StringBuilder or StringBuffer objects accept a boolean or, char or, char array or, double or, float or, int or, long or, String value as parameter and adds it to the current object.You can append the required double value to the method and retrieve a String from obtained StringBuffer ... Read More

Can we define an enum inside a method in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 11:35:52

3K+ Views

Enumerations in Java represents a group of named constants, you can create an enumeration using the following syntax −enum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }We can an enumeration inside a class. But, we cannot define an enum inside a method. If you try to do ... Read More

Can we define an enum inside a class in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 11:34:06

17K+ Views

Enumerations in Java represents a group of named constants, you can create an enumeration using the following syntaxenum Days {    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }Yes, we can define an enumeration inside a class. You can retrieve the values in an enumeration using the values() method.ExampleLive Demopublic class ... Read More

How to search a directory with file extensions in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 11:21:27

1K+ Views

Following example prints the files in a directory based on the extensions −Exampleimport java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.stream.Stream; public class Demo {    public static void main(String[] args) throws IOException {       Stream path = Files.walk(Paths.get("D:\ExampleDirectory"));       System.out.println("List of PDF files:");   ... Read More

How to read all files in a folder to a single file using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 08-Feb-2021 11:10:12

9K+ Views

The listFiles() method of the File class returns an array holding the objects (abstract paths) of all the files (and directories) in the path represented by the current (File) object.To read the contents of all the files in a folder into a single file −Create a file object by passing ... Read More

Previous 1 ... 3 4 5 6 7 ... 47 Next
Advertisements