Programming Articles

Page 2537 of 2547

When is a semicolon after } mandated in C++ Program?

George John
George John
Updated on 30-Jul-2019 3K+ Views

A semicolon after a close brace is mandatory if this is the end of a declaration. In case of braces, they have used in declarations of class, enum, struct, and initialization syntax. At the end of each of these statements, we need to put a semicolon. For example, class X {}; // same declaration for struct as well enum Y {}; int z[] = {1, 2}; A semicolon by itself is an empty statement, and you'll be able to add additional ones anywhere a statement is legal. Therefore it might be legal to place a ...

Read More

Constructors of StringTokenizer class in Java.

Anjana
Anjana
Updated on 30-Jul-2019 303 Views

Following are the important constructors of the StringTokenizer class.Sr.No.Constructor & Description1StringTokenizer(String str)This constructor a string tokenizer for the specified string.2StringTokenizer(String str, String delim)This constructor constructs string tokenizer for the specified string.3StringTokenizer(String str, String delim, boolean returnDelims)This constructor constructs a string tokenizer for the specified string.

Read More

When are python objects candidates for garbage collection?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 30-Jul-2019 300 Views

A python object or variable will be eligible for garbage collection as soon as all references to it go out of scope or are manually deleted (del x). We would have to presume there were no references to the object anywhere else for it to be garbage collected.

Read More

Why can't static method be abstract in Java?

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

A static method belongs to class not to object instance thus it cannot be overridden or implemented in a child class. So there is no use of making a static method as abstract.

Read More

How to convert List to int[] in Java?

Sreemaha
Sreemaha
Updated on 30-Jul-2019 1K+ Views

You can simply iterate through list and fill the array as shown below −import java.util.ArrayList; import java.util.List; public class Tester {    public static void main(String[] args) {       List list = new ArrayList();       list.add(new Integer(1));       list.add(new Integer(2));       list.add(new Integer(3));       list.add(new Integer(4));       int[] array = new int[list.size()];       for(int i=0;i

Read More

Difference between declaring a variable before or in a Java loop.

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

Performance wise, there is hardly any difference. But it is good to keep a variable local to the scope it is used. So declaring a variable inside Java loop is generally preferred.

Read More

Why there is not do...while loop in Python?

Pythonista
Pythonista
Updated on 30-Jul-2019 1K+ Views

PEP 315 (Python Enhancement Proposal) to include do..while statement has been rejected because it doen't fit in the general format of indented block statement: indented block used by every other Python compound statement. In words of Guido Van Rossum -  "Please reject the PEP. More variations along these lines won't make the language more elegant or easier to learn. They'd just save a few hasty folks some typing while making others who have to read/maintain their code wonder what it means".

Read More

How to concatenate byte array in java?

mkotla
mkotla
Updated on 30-Jul-2019 3K+ Views

You ByteArrayOutputStream to write byte arrays and get the result using its toByteArray() method.import java.io.ByteArrayOutputStream; import java.io.IOException; public class Tester { public static void main(String[] args) throws IOException { byte[] a = { 1,2,3}; byte[] b = { 4,5,6}; ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(a); baos.write(b); byte[] c = baos.toByteArray(); for(int i=0; i< c.length ; i++){ System.out.print(c[i] +" "); } } }Output1 2 3 4 5 6

Read More

What does 'using namespace std' mean in C++?

Moumita
Moumita
Updated on 30-Jul-2019 12K+ Views

Consider a situation, when we have two persons with the same name, Piyush, in the same class. Whenever we need to differentiate them definitely we would have to use some additional information along with their name, like either the area, if they live in a different area or their mother’s or father’s name, etc.The same situation can arise in your C++ applications. For example, you might be writing some code that has a function called xyz() and there is another library available which is also having same function xyz(). Now the compiler has no way of knowing which version of ...

Read More

Why java is both compiled and interpreted language.

Jai Janardhan
Jai Janardhan
Updated on 30-Jul-2019 922 Views

Yes, a java program is first compiled into bytecode which JRE can understand. ByteCode is then interpreted by the JVM making it as interpreted language.

Read More
Showing 25361–25370 of 25,467 articles
Advertisements