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 inherited is super class or, parent class.In inheritance a copy of super class members is created in the sub class object. Therefore, using the sub class object you can access the members of the both classes.Multiple inheritance is where one class inherits the properties of multiple classes. In other words, ... Read More
Sometimes all the columns in a data frame have similar data characteristics representing a particular variable. For example, having a data frame containing five columns each with heights of people. To convert this type of data frame into a vector we can use as.vector function along with the as.matrix function. The as.matrix will read the data frame columns so that the array of values can be created.Example1 Live DemoConsider the below data frame −set.seed(101) x1
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 inherited is super class or, parent class.In inheritance a copy of super class members is created in the sub class object. Therefore, using the sub class object you can access the members of the both classes.Converting a super class reference variable into a sub class typeYou can try to convert ... Read More
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 inherited is super class or, parent class.In inheritance a copy of super class members is created in the sub class object. Therefore, using the sub class object you can access the members of the both classes.Converting a sub class variable into a super class typeYou can directly assign a sub ... Read More
To create a step histogram using ggplot2, we can use geom="step" argument inside stat_bin function. For example, if we have a data frame that contains a single column then the step histogram can be created using the command − ggplot(df,aes(x))+stat_bin(geom="step",bins=30)Example Live DemoConsider the below data frame −set.seed(14) x
If we have multiples data frames of same size stored in a list and we believe that these data frames have similar characteristic then we can create a single data frame. This can be done with the help of do.call. For example, if we have a list defined with the name List containing data frames with equal number of rows with their names then a single data frame can be created do.call(rbind,unname(List)).Example Live Demodf1
The String class of the java.lang package represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. Strings are constant, their values cannot be changed after they are created.The valueOf() method of the String class accepts a char or, char array or, double or, float or, int or, long or an object as a parameter and returns its String representation.ExampleLive Demoimport java.util.Scanner; public class ConversionOfDouble { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter a double value:"); ... Read More
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 (or, StringBuilder) objects.ExampleLive Demoimport java.util.Scanner; public class ConversionOfDouble { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter a double value:"); double d = sc.nextDouble(); StringBuffer sb = new StringBuffer(); sb.append(d); ... Read More
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 so it generates a compile time error saying “enum types must not be local”.Examplepublic class EnumExample{ public void sample() { enum Vehicles { Activa125, Activa5G, Access125, Vespa, TVSJupiter; } } }ErrorEnumExample.java:3: error: enum types must not be local ... Read More
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 EnumerationExample { enum Enum { Mango, Banana, Orange, Grapes, Thursday, Apple } public static void main(String args[]) { Enum constants[] = Enum.values(); System.out.println("Value of constants: "); for(Enum d: constants) { ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP