Linked Questions

14 votes
3 answers
9k views

I am studying for an exam about Java. While I was studying, I have encountered syntaxes in java which are unfamiliar to me. Such as a curly braces({}) unside a class body without a name, some has a ...
steven0529's user avatar
  • 1,573
1 vote
4 answers
14k views

i find this example and i want to understand the logic behind it ? how constructors and static blocks and initializer blocks works in inheritance ? in which stage each one is called ? public class ...
oussama.elhadri's user avatar
-4 votes
1 answer
197 views

I recently came across the following bit of java syntax: static { ... } apparently this is known as a "static initializer" (see Static Block in Java) and is "executed when the class is loaded". When ...
tSchema's user avatar
  • 213
-1 votes
1 answer
88 views

`In jav8, We are supporting Constructor in abstract class. why we need Constructor in abstract class, if we are having static and non-static block support Code :- abstract class a{ static {...
SavinayPatil's user avatar
134 votes
10 answers
90k views

We can put code in a constructor or a method or an initialization block. What is the use of initialization block? Is it necessary that every java program must have it?
Sumithra's user avatar
  • 6,725
2 votes
5 answers
15k views

Hi I'm having problem with initialization in java, following code give me compile error called : expected instanceInt = 100; but already I have declared it. If these things relate with stack and heap ...
ddfnfal's user avatar
  • 1,427
6 votes
6 answers
11k views

I am very new to Java and trying to learn the subject, having previous programming exposure in only HTML/CSS. I have started with Herbert Schildt and progressed through a few pages. I am unable to ...
S. Chatterjee's user avatar
2 votes
5 answers
570 views

public class myclass{ static{ //some statements here } //some variables declared here //some functions defined here }
Vijay Bhaskar Semwal's user avatar
4 votes
3 answers
4k views

I have written a little test application that looks like this: import javafx.application.Application; import javafx.application.Platform; import javafx.stage.Stage; public class Test extends ...
mrbela's user avatar
  • 4,677
3 votes
2 answers
277 views

I'm trying to clean the code of a class that use initialization bloks in a manner I would never do, and I'm just wondering if I am missing some informations. The code looks like this: @Entity class ...
holap's user avatar
  • 438
0 votes
1 answer
1k views

I've just learned about init block. I know both(constructor & non-static init block) can be used to initialise members of a class . So, I wanted to know which out of the two is better/more_useful ...
user avatar
1 vote
1 answer
1k views

When using com.sun.net.httpserver.HttpServer, I observed the following in an application: When run not from a jar (e.g. from Eclipse or on command line) System.setProperty("java.net.preferIPv4Stack", "...
Jason C's user avatar
  • 40.6k
1 vote
3 answers
96 views

What's wrong with the below program? package test; public class Test { byte[] array = new byte[2]; array[0] = 'A'; array[1] = 'B'; } Look,the IDE indicate some problems(click to enlarge)...
Ebrahim Ghasemi's user avatar
3 votes
2 answers
140 views

I was reading an open-source code, and there was a constructor designed like this: public class FeatureSequence2FeatureVector extends Pipe implements Serializable { boolean binary; public ...
pandagrammer's user avatar
-1 votes
1 answer
558 views

Consider the following example: public class Constructor { Constructor(int i) { System.out.println(i); } } public class Test { Constructor c1 = new Constructor(1); ...
Jerry_W's user avatar
  • 125

15 30 50 per page