Posts
 
Reputation
Joined
Last Seen
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
15% Quality Score
Upvotes Received
1
Posts with Upvotes
1
Upvoting Members
1
Downvotes Received
10
Posts with Downvotes
5
Downvoting Members
5
2 Commented Posts
0 Endorsements
Ranked #3K
~17.1K People Reached
Favorite Tags

57 Posted Topics

Member Avatar for daudiam

Both DataOutputStream and PrintStream do basically the same thing - convert primitive types and Strings to bytes before writing them (writeUTF() is an exception). Why different classes ?

Member Avatar for JamesCherrill
0
1K
Member Avatar for daudiam

I thought that setting up the PATH variable was a must if we wanted to use java or javac commands on linux (preferably in the bashrc file), but I am able to use these commands anywhere without setting up the PATH variable.. Similarly, without specifying '.' in the CLASSPATH variable …

Member Avatar for odubanjo.ismail
0
184
Member Avatar for daudiam

[CODE]@Local public interface EJBA{ // declares a method 'validate' } @Stateless public class EJBABean implements EJBA{ // implements the method 'validate' } class Model{ @EJB private EJBA ejbA; public void doSomething(){ ejbA.validate(); } } [/CODE] Now, if I do the following from the execute method of a Struts 1.2 action …

0
105
Member Avatar for daudiam

I want to reorder the rows by dragging them which is accomplished by the code below, but the void (placeholder) should be of a red color while the drag is taking place - this part is not happening : [CODE]<html> <head> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery.ui.sortable.min.js"></script> <script> $(function() { …

0
141
Member Avatar for daudiam

I understand that int values, when autoboxed, are interned i.e no 2 objects containing the same int are present, and so we can compare two Integers by == So why does the following happen :[CODE]Integer iRef1=1000; Integer iRef2=1000; System.out.println(iRef1 == iRef2); System.out.println(iRef1.equals(iRef2));[/CODE] This prints [CODE]false true[/CODE] On the other hand, …

Member Avatar for daudiam
0
126
Member Avatar for daudiam

Why do local inner classes not allow static variables ? The static fields of the classes could at least have been allowed access from the local method ?

Member Avatar for ~s.o.s~
0
164
Member Avatar for daudiam

Consider the following codes : File : C3.java [CODE]package G; public class C3 { protected int a=5; }[/CODE] File : R3.java [CODE]import G.C3; class R2 extends C3 { void doit() { a=7; } } class R1 extends R2 { void doit(R2 b) { a=8; b.a=1; // (1) } }[/CODE] It …

Member Avatar for daudiam
0
209
Member Avatar for daudiam

[CODE]class R2 { final int t; void doit(){ t=7; } }[/CODE] Blank finals allow us to declare a final variable without explicitly initializing it. We can initialize it only once later. Then, why is th above code not working ?

Member Avatar for daudiam
0
162
Member Avatar for daudiam

I can understand that the subtype covariance relation should not hold for parameterized types, but why should it hold for arrays ? One of the books (Khalid Moghul) said [QUOTE]This relation holds for arrays because the element type is available at runtime[/QUOTE] How does the element type being available at …

Member Avatar for daudiam
0
171
Member Avatar for daudiam

Consider the following code : [CODE]class R2<E> { E a; E get() { return a; } void set(E a) { this.a=a; } } class R3 { void doit(R2 a) // (1) { a.set(new Integer(5)); } }[/CODE] When I compile the file containing class R3, it rightly gives an unchecked warning …

Member Avatar for daudiam
0
167
Member Avatar for daudiam

Consider the following code : [CODE]class R2<E> { E a; E get() { return a; } void set(E a) { this.a=a; } public static void main(String aa[]) { R2 nn1=new R2<Integer>(); nn1.set("hello"); (1) //String r=nn1.get(); //Integer t=nn1.get(); } }[/CODE] In line (1), an unchecked warning is given as the compiler …

Member Avatar for daudiam
0
205
Member Avatar for daudiam

I can't understand the following statement [QUOTE]The Hotspot VM now implements Thread.yield() using the Windows SwitchToThread() API call. This call makes the current thread give up its current timeslice, but not its entire quantum.[/QUOTE] given at [URL="http://www.javamex.com/tutorials/threads/yield.shtml"]http://www.javamex.com/tutorials/threads/yield.shtml[/URL] I understand that after a thread yields, other threads get a chance to …

Member Avatar for ~s.o.s~
0
691
Member Avatar for daudiam
Member Avatar for daudiam

gedit uses UTF encoding. Therefore, if we store binary data in the file (like through DataOutputStream's writeInt() or writeByte(), etc.), gedit would rightly complain, but if we write something through the writeUTF() function, then gedit should be able to open it as the data is written is UTF which it …

Member Avatar for daudiam
0
136
Member Avatar for daudiam

Using a BufferedInputStream is useful because it cuts down on read system calls. But the same effect can be produced, say in reading a file, if we use FileInputStream's read method that takes a byte array as input. A lot of bytes are read in a single call. Am I …

Member Avatar for daudiam
0
250
Member Avatar for daudiam

FileInputStream inherits from InputStream which has a mark() method which does nothing. FileInputStream itself doesn't define any mark() method. Even then, if I wrap a FileInputStream object inside a BufferedInputStream object and call markSupported() on it, it returns true. In the docs, it says that the mark() method of any …

Member Avatar for daudiam
0
633
Member Avatar for daudiam

I want to make a GUI application in which I want to do something continuously (i.e. in while loop) in a different thread, until the user presses a button. In this other thread, I am accessing GUI elements and hence I have to use [B]SwingUtilities.invokeLater()[/B] for this thread. But since …

Member Avatar for daudiam
0
1K
Member Avatar for daudiam

I downloaded data from google.com/favicon.ico and saved it in a file "icon.png" using the following: [CODE]URL url=new URL("http://www.google.com/favicon.ico"); InputStream ss=url.openStream(); byte bytes[]=new byte[100000]; int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead=ss.read(bytes, offset, bytes.length-offset)) >= 0) { offset += numRead; } FileOutputStream out=new FileOutputStream("icon.png"); out.write(bytes);[/CODE] …

Member Avatar for daudiam
0
199
Member Avatar for gingerfish

[QUOTE]when the random kMean is 1[/QUOTE] kMean is an array. What does the above statement mean ? In which line the error occurs ?

Member Avatar for gingerfish
0
136
Member Avatar for daudiam

Forward referencing is allowed during declarations when the undeclared variable is used in the LHS of an expression, but not if its in the RHS. Therefore, the following won't work : [CODE]class A { int a=h; int h; }[/CODE] But the following code works : [CODE]class A { int a=this.h; …

Member Avatar for daudiam
0
227
Member Avatar for daudiam

Is it true that during autoboxing, the type.valueOf() method is called (which creates a new object only if another with the same primitive constant is not in the intern list. This applies to cases where interning is allowed. Otherwise, it creates a new object using new() ). Is this right …

Member Avatar for daudiam
0
141
Member Avatar for daudiam

[CODE]class hello { } class hello1 { public static void main(String aa[]) { hello ob[]={new hello(),new hello(),new hello()}; hello ob1[]=ob.clone(); // 1 } }[/CODE] ob is an array which is also treated as an object, and hence has a default clone method which is called at (1). But the default …

Member Avatar for daudiam
0
228
Member Avatar for hajjo

adfaec, 181db77, etc. these are memory addresses of the object that's created. java.lang.Object is the fully qualified name of the class.

Member Avatar for jon.kiparsky
0
85
Member Avatar for daudiam

From my home directory, I created a directory [B]pkg[/B] and wrote 2 files [B]A.java[/B] and [B]B.java[/B] in it. [B]A.java[/B] [CODE]package pkg; class A { B b; }[/CODE] [B]B.java[/B] [CODE]package pkg; class B { }[/CODE] I went back to my home directory and typed the following : [CODE]javac -classpath . /pkg/A.java[/CODE] …

Member Avatar for ~s.o.s~
0
211
Member Avatar for daudiam

The following assignment would work [CODE]float a=3;[/CODE] But the following won't :[CODE] Float a=3;[/CODE] Shouldn't 3 be automatically promoted to float (as widening conversions don't require an explicit cast) and then Boxed to Float type ? Is it because of a rule I read in Khalid Mogul's Java book ? …

Member Avatar for daudiam
0
129
Member Avatar for daudiam

Suppose B class inherits A. Then the following code works. [CODE]A ob; ob=new B(); [/CODE] but the following throws an ArrayStoreException : [CODE]A ob[]=new B[2]; ob[0]=new A();[/CODE] Is [B]ob[0][/B] a reference of type A or B ? In the first code, [B]ob[/B] was a reference of type A and therefore …

Member Avatar for daudiam
0
57
Member Avatar for NewOrder

If I understand correctly, u can make the pieces array public, import the entire file containing chessInterface into the file containing the Bishop class (if the 2 are not in the same folder, that is) and directly access "pieces" in the Bishop class, via an object of the chessInterface class.

Member Avatar for NormR1
0
200
Member Avatar for satish2

The standard Java tools to display the web page are not that powerful and won't be able to display much more than basic HTML, and a few other things. For a complete rendering of web pages, you should use a web engine like WebKit or Gecko in the backend. If …

Member Avatar for daudiam
0
81
Member Avatar for daudiam

I was reading an SCJP book by Khalid Mughal and I came across a statement [QUOTE]Enum constants are static members[/QUOTE] and another [QUOTE]Enum constant is an instance of its enum type[/QUOTE]. I am unable to reconcile the 2 statements. Are the constants static members or are they instances ? (Instances …

Member Avatar for daudiam
0
364
Member Avatar for daudiam

Its said that enums can be nested as top-level type declaration. Does it mean that it can be declared as a data member of a class, but it cannot be declared as a data member of a nested class as the nested class id not top-level ?

Member Avatar for daudiam
0
79
Member Avatar for daudiam

I am trying to develop a software that can automatically search and download the correct subtitle for my movies. I need to compare the fps rates. How can i find the fps of a movie in java ?

Member Avatar for daudiam
0
117
Member Avatar for daudiam

[CODE]class Faltu { public static void main(String aa[]) { int a=4,b; if (a==4) b=5; System.out.println ("b="+b); } }[/CODE] Here it says : "variable b might not have been initialized", but in the following : [CODE] class Faltu { public static void main(String aa[]) { int a=4,b; if (true) b=5; System.out.println …

Member Avatar for daudiam
1
89
Member Avatar for daudiam

I compiled a HelloWorld example using QtJambi. But on running it, it said "[B]failed to unpack native libraries[/B]. The complete error was : [CODE]daud@daud-laptop:~$ java -d32 com.trolltech.examples.tutorial.HelloWorld Exception in thread "main" java.lang.ExceptionInInitializerError at com.trolltech.qt.QtJambiObject.<clinit>(QtJambiObject.java:60) at com.trolltech.examples.tutorial.HelloWorld.main(HelloWorld.java:58) Caused by: java.lang.RuntimeException: Loading library failed, progress so far: Unpacking .jar file: 'qtjambi-linux32-gcc-4.6.3.jar' Checking …

Member Avatar for daudiam
0
250
Member Avatar for daudiam

Applications like browsers, etc. are written in Java, Python, etc. But when they are installed on a system that doesn't have Java or Python installed, how does it ensure that its code runs there ? Actually, I wanted to write a browser in Java with WebKit as engine. Since the …

0
40
Member Avatar for daudiam

I used the following code to download HTML files and subtitle files over the Internet. But when I give the url of a Youtube video, the download stops very quickly and though some file IS downloaded, it doesn't open. Why ? [CODE]class read { public static void main(String aa[])throws IOException …

Member Avatar for NormR1
0
260
Member Avatar for daudiam

b=c/d++; In this, first d is incremented (because ++ has a higher priority than / or =), but c is divided by the unincremented value of d. Thus, the order of evaluation in this case is well-defined. But if we had written the above as: b=(c)/(d++) then which operand ( …

Member Avatar for daudiam
0
241
Member Avatar for daudiam

Just wanted to know that to develop a speech recognition software, should I download the Sphinx4 versions of the javax.speech and javax.speech.recognition API, or I should implement the API myself ?

0
95
Member Avatar for daudiam

[CODE]ReferenceQueue rq=new ReferenceQueue(); SoftReference <class> ob=new SoftReference<class>(object_of_class,rq);[/CODE] The API says that all weak and soft references are cleared as they are enqueued. So, for the above code, as soon as the JVM sees that "object_of_class" is softly reachable, it will enqueue it, and clear the soft reference. "clearing the soft …

Member Avatar for daudiam
0
100
Member Avatar for daudiam

When a variable goes out of scope in Java, is it immediately removed from stack and one strong reference to the object it pointed to removed ?

Member Avatar for daudiam
0
4K
Member Avatar for daudiam

Static fields and methods are allocated memory once only, when they are first referenced, irrespective of the no. of objects u later create. But, memory is allocated for its data members each time an object is created. But what about the non-static methods, they don't change for each object. So …

Member Avatar for JamesCherrill
0
137
Member Avatar for daudiam

Hi, I'm just a little confused as to what to we call a reference. [CODE]A ob=new B();[/CODE] Here B is a subclass of A. Should we say "ob is a reference of A which has been assigned an object of B" or "ob is a variable of A which has …

Member Avatar for JamesCherrill
0
94
Member Avatar for daudiam

The ConcurrentHashMap is thread safe without locking the entire table but it doesn't remove the race conditions like if we query for a key and at that time the key is not there, so in the next instruction we add the key's entry to the map. Between the two things, …

Member Avatar for stephen84s
0
741
Member Avatar for daudiam

Ordinary Maps use the following test for equality (k1==null ? k2==null : k1.equals(k2)).) IdentityHashMap uses k1==k2. My question is that even Object's equals() method returns k1==k2. Only when the Object's equals method is overridden inside a class, does it perform content based equality comparison. So, IdentityHashMap could have used Object's …

Member Avatar for daudiam
0
129
Member Avatar for daudiam

For the Object class' equals method, the API says :[QUOTE]The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object …

Member Avatar for daudiam
0
226
Member Avatar for daudiam

The API says that the implementation of BlockingQueue are thread safe, but about the drainTo method, it says : [QUOTE]"This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or …

Member Avatar for daudiam
0
800
Member Avatar for daudiam

I tried to do this [CODE]ArrayList<String> a=new ArrayList<String>(2); a.add("dss"); a.add("dsfs"); a.add("fsfs"); [/CODE] Though i have specified a limit of 2 on the collection, i am able to add more. If this is general about Collections, is there any Collection which sets a limit and strictly follows it ?

Member Avatar for daudiam
0
81
Member Avatar for daudiam

[CODE]class A extends B { C ob1=new C(); D ob2=new D(); protected void finalize() { System.out.println("Finalizing A"); super.finalize(); } public static void main(String ss[]) { new A(); System.gc(); } }[/CODE] Though System,gc() doesn't guarantee the running of finalization, my question is if the JVM is able to run the finalizations …

Member Avatar for daudiam
0
296
Member Avatar for daudiam

[CODE]cmd='date | wc' $cmd [/CODE] If this script is executed, an error is generated. The reason written was that "The execution fails because the pipe is not expanded and is passed to date as an argument". What is meant by expansion of pipe. When we execute [B]date | wc[/B] on …

0
100
Member Avatar for daudiam

During runtime when a program asks for a memory block (say, by malloc()), its provided with a block of virtual addresses, say 0x10000000 to 0x1000A00 (for 32 bit). During the execution, other processes are incorporated into the main memory and pages 0x10000000-0x100000A0 are paged out. After some time, the program …

0
113
Member Avatar for daudiam

java class files are not loaded into memory till the time they are referenced. If this is true, then the use of import statement is just to save a bit of typing. Is it the case ?

Member Avatar for JamesCherrill
0
130

The End.