Found 7442 Articles for Java

Single dimensional array in Java

V Jyothi
Updated on 17-Jun-2020 08:12:12

952 Views

Following is a simple example of a single dimensional array.Example Live Demopublic class Tester {    public static void main(String[] args) {       double[] myList = {1.9, 2.9, 3.4, 3.5};       // Print all the array elements       for (double element: myList) {          System.out.print(element + " ");       }    } }Output1.9 2.9 3.4 3.5

Types of Array in Java

varun
Updated on 30-Jul-2019 22:30:21

331 Views

Java supports single dimensional and multidimensional arrays. See the example below:Example Live Demopublic class Tester {    public static void main(String[] args) {       double[] myList = {1.9, 2.9, 3.4, 3.5};       // Print all the array elements       for (double element: myList) {          System.out.print(element + " ");       }       System.out.println();       int[][] multidimensionalArray = { {1,2},{2,3}, {3,4} };       for(int i = 0 ; i < 3 ; i++) {          //row          for(int j = 0 ; j < 2; j++) {             System.out.print(multidimensionalArray[i][j] + " ");          }          System.out.println();       }    } }Output1.9 2.9 3.4 3.5 1 2 2 3 3 4

Advantages and disadvantages of arrays in Java

Prabhas
Updated on 17-Jun-2020 07:50:41

2K+ Views

BenefitsEasier access to any element using the index.Easy to manipulate and store large data.DisadvantagesFixed size. Can not be increased or decrease once declared.Can store a single type of primitives only.

Method of Object class in Java

vanithasree
Updated on 17-Jun-2020 08:02:02

2K+ Views

Following are various methods of Object class −protected Object clone() - Used to create and return a copy of this object. boolean equals(Object obj) - Used to indicate whether some other object is "equal to" this one.protected void finalize() - garbage collector calls this method on an object when it determines that there are no more references to the object.Class getClass() - Used to get the runtime class of this Object.int hashCode() - Used to get a hash code value for the object.void notify() - Used to wake up a single thread that is waiting on this object's monitor.void notifyAll() - ... Read More

java access modifiers with method overriding

Giri Raju
Updated on 24-Feb-2020 06:03:42

6K+ Views

Yes, an overridden method can have a different access modifier but it cannot lower the access scope.The following rules for inherited methods are enforced -Methods declared public in a superclass also must be public in all subclasses.Methods declared protected in a superclass must either be protected or public in subclasses; they cannot be private.Methods declared private are not inherited at all, so there is no rule for them.

Is there any tool that can convert an XSD file to a Python class as JAXB does for Java?

Rajendra Dharmkar
Updated on 30-Jul-2019 22:30:21

1K+ Views

I would recommend generateDS for converting a XSD file to a Python class . In my opinion, it is a good tool for the said purpose.It (generatS) generates the Python class with all methods (setters and getters, export to XML, import from XML). It does a good job and works very well !.

Nested Interface in Java

Shriansh Kumar
Updated on 17-Apr-2025 18:51:56

4K+ Views

In Java, an interface defined inside another interface or class is called nested interface. Interfaces are similar to classes, but they not contain instance variables, and their methods are declared without any body. You can specify what a class must do, but not how it does it using the interface keyword. In this article, we will learn about nested interfaces in Java. What is a Nested Interface in Java As mentioned earlier, we can declare an interface within another interface or class. Such an interface is termed as nested interface. It follows the same syntax as a regular interface ... Read More

Nested Interface in Java

Shriansh Kumar
Updated on 17-Apr-2025 18:51:56

4K+ Views

In Java, an interface defined inside another interface or class is called nested interface. Interfaces are similar to classes, but they not contain instance variables, and their methods are declared without any body. You can specify what a class must do, but not how it does it using the interface keyword. In this article, we will learn about nested interfaces in Java. What is a Nested Interface in Java As mentioned earlier, we can declare an interface within another interface or class. Such an interface is termed as nested interface. It follows the same syntax as a regular interface ... Read More

Nested Interface in Java

Shriansh Kumar
Updated on 17-Apr-2025 18:51:56

4K+ Views

In Java, an interface defined inside another interface or class is called nested interface. Interfaces are similar to classes, but they not contain instance variables, and their methods are declared without any body. You can specify what a class must do, but not how it does it using the interface keyword. In this article, we will learn about nested interfaces in Java. What is a Nested Interface in Java As mentioned earlier, we can declare an interface within another interface or class. Such an interface is termed as nested interface. It follows the same syntax as a regular interface ... Read More

Difference between abstract class and interface

Kiran Kumar Panigrahi
Updated on 28-Jul-2022 08:34:09

6K+ Views

An abstract class can contain both abstract and non-abstract methods, whereas an Interface can have only abstract methods. Abstract classes are extended, while Interfaces are implemented. Read through this article to find out the other differences between an Abstract Class and an Interface and how they are used in real programs.What is an Abstract Class?An abstract class acts as a template that stores the methods and data members of a program. You should use an abstract class when you expect that it will inherited by different sub-classes with common methods and fields.Abstract classes may or may not contain abstract methods, ... Read More

Advertisements