Programming Articles

Page 2534 of 2547

The auto storage class in C++

Jennifer Nicholas
Jennifer Nicholas
Updated on 30-Jul-2019 285 Views

In C, The auto storage class specifier lets you explicitly declare a variable with automatic storage. The auto storage class is the default for variables declared inside a block. A variable x that has automatic storage is deleted when the block in which x was declared exits.You can only apply the auto storage class specifier to names of variables declared in a block or to names of function parameters. However, these names by default have automatic storage. Therefore the storage class specifier auto is usually redundant in a data declaration.It was initially carried over to C++ for syntactical compatibility only, ...

Read More

How do we compare String in Java

Giri Raju
Giri Raju
Updated on 30-Jul-2019 301 Views

https://www.tutorialspoint.com/javaexamples/string_compare.htm

Read More

What is the difference between the size of ArrayList and length of Array in Java?

Srinivas Gorla
Srinivas Gorla
Updated on 30-Jul-2019 2K+ Views

ArrayList doesn't have length() method, the size() method of ArrayList provides the number of objects available in the collection.Array has length property which provides the length or capacity of the Array. It is the total space allocated during the initialization of the array.

Read More

How many Python classes should I put in one file?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 30-Jul-2019 3K+ Views

Python code is organized in files called "modules" and groups of related modules called “packages".A module is a distinct unit that may have one or more closely-related classes. Modules need to be imported before they are read, used, maintained and extended if needed. So a module is a unit or reuse.The rule is this: a module is the unit of reuse. Everything in Python libraries and other Python applications is either a module or a package of modules.There is no limit on how many classes one can put in a file or a module. It all depends on how big ...

Read More

how to convert Object array to String array in java

Sai Nath
Sai Nath
Updated on 30-Jul-2019 5K+ Views

As list.toArray() returns an Object[], it can be converted to String array by passing the String[] as parameter. See the example below.import java.util.ArrayList; import java.util.List; public class Tester { public static void main(String[] args) { List data = new ArrayList(); data.add("A"); data.add("B"); data.add("C"); //Object[] objects = data.toArray(); String[] strObjects = data.toArray(new String[0]); for(String obj: strObjects) { System.out.println(obj); } } }OutputA B C

Read More

Can a Vector contain heterogeneous objects in Java?

Ramu Prasad
Ramu Prasad
Updated on 30-Jul-2019 1K+ Views

Since a vector stores elements in the form of objects, you can store objects of various types (heterogeneous) in it.Example:import java.util.*; class Demo{} public class VectorSample {    public static void main(String args[]) {       Demo obj = new Demo();       Vector v = new Vector(3, 2);       System.out.println("Initial size: " + v.size());       System.out.println("Initial capacity: " + v.capacity());       v.addElement(new Integer(1));       v.addElement(new String("krishna"));       v.addElement(new Float(3.5f));       v.addElement(obj);       System.out.println("Capacity after four additions: " + v.capacity());    } }

Read More

Checking for Null or Empty or White Space Only String in Java.

Anjana
Anjana
Updated on 30-Jul-2019 2K+ Views

We can verify whether the given string is empty using the isEmpty() method of the String class. This method returns true only if length() is 0. Example import java.lang.*; public class StringDemo {     public static void main(String[] args) {         String str = "tutorialspoint";         // prints length of string         System.out.println("length of string = " + str.length());         // checks if the string is empty or not         System.out.println("is this string empty? = " + str.isEmpty());     } } Output length of string = 14 is this string empty? = false

Read More

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

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 30-Jul-2019 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 !.

Read More

What does the method add(E element) do in java?

Nikitha N
Nikitha N
Updated on 30-Jul-2019 513 Views

The add(E e) method of the java.util.ArrayList class appends the specified element E to the end of the list.Example:import java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) {       ArrayList arrlist = new ArrayList(5);       arrlist.add(15);       arrlist.add(20);       arrlist.add(25);       for (Integer number : arrlist) {          System.out.println("Number = " + number);       }    } }Output:Number = 15 Number = 20 Number = 25

Read More
Showing 25331–25340 of 25,467 articles
Advertisements