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
~16.6K People Reached
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
182
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
103
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
137
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
124
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
162
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
206
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
155
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
169
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
161
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
202
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
672
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
134
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
247
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
625
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
194
Member Avatar for gingerfish

Hello I have a code here. it generates random 2d array [B]kMean[2][3][/B] and then this program calculates the distance between random generated [B]kMean[2][3][/B]s and [B]data[][][/B]. but the problem is, when the random kMean is 1, then it calculates the distance, but when the number or kMean becomes more than one, …

Member Avatar for gingerfish
0
130
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
220
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
137
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
225
Member Avatar for hajjo

Just a begginner question Object x = new Object(); System.out.println(x); everytime i get sthg. 16:18:35,222 INFO [STDOUT] --java.lang.Object@adfaec 16:19:26,937 INFO [STDOUT] --java.lang.Object@181db77 16:21:34,538 INFO [STDOUT] --java.lang.Object@14e5e21 what is the thing being printed? the object memory place? please help a beginner

Member Avatar for jon.kiparsky
0
82
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
208
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
125
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
54
Member Avatar for NewOrder

i want to import an array, but i cant.. i have my chess class.. and one method that tries to check whether there is a check. basically like this.. [CODE] if(pieces[columnStartN][rowStartN].isMoveValid(columnStartN,rowStartN,columnEndN,rowEnd) && pieceDevour){ pieces[columnStartN][rowStartN]=null; pieces[columnStartN][rowStartN]=pieces[columnEndN][rowEnd]; } rowStartN=rowEnd; columnStart=columnEnd; int kingRow=0; int kingColumn=0; chessPiece="BKing"; int c=0; int pieceColumn=0; int pieceRow=0; for(int …

Member Avatar for NormR1
0
189
Member Avatar for satish2

hi everyone I want to develop a web browser.....can anyone suggest me how to develop it in java ...

Member Avatar for daudiam
0
78
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
361
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
76