Tybon Wu

Ranch Hand
+ Follow
since Jun 18, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tybon Wu

If you meant dynamic type binding for variables then no Java does not support it. Java variable type is statically bound during the variable declaration. Dynamic type binding is supported on other languages such as Lisp, where variable type is bound when it is assigned a value.
Do you agree with the following?

A n dimensional array is composed of series of n-1 dimensional arrays.
A 4 dimensional array is composed of series of 3 dimensional arrays.
A 3 dimensional array is composed of series of 2 dimensional arrays.
...
...
...

If you agree with the above, then you should agree with the following, which is another way of saying the above:

An element of a n dimensional array is a n-1 dimensional array.
An element of a 4 dimensional array is a 3 dimensional array.
An element of a 3 dimensional array is a 2 dimensional array.
...
...
...

OK if you are still in agreement, we can go back to the previous example:

byte b2[][][][] = new byte [2][3][1][2];

b2 is a 4 dimensional array

We just agreed from above that "An element of a 4 dimensional array is a 3 dimensional array"
And since b2[0] is an element of b2
Therefore b2[0] must be 3 dimensional

We just agreed from above that "An element of a 3 dimensional array is a 2 dimensional array"
And since b2[0][0] is an element of b2[0]
Therefore b2[0][0] must be 2 dimensional
...
...
...
You can only assign arrays of the same dimension to another array. In choice a), b2[0][2] is a 2-dimensional array, and b is also a 2-dimensional array, so b2[0][2]=b is legal. In choice c), b2[1][1][0] is a 1-dimensional array, but b[0][0] is a byte, so b2[1][1][0]=b[0][0] is not legal.

Given byte b2[][][][] = new byte [2][3][1][2];
the following are true:

b2 is a 4-dimensional array
b2[0] is a 3-dimensional array
b2[0][0] is a 2-dimensional array
b2[0][0][0] is a 1-dimensional array
b2[0][0][0][0] is a byte

Hopefully that will make it clear for you...
Traditional university education definitely has its benefits, but that's not the argument here. During the early 90's, the information industry exploded. At the time, there was no MCSD's or SCJD's. Companies need programmers, and the most capable people were CS graduates. That's why at the time if you had a degree in CS you were pratically guaranteed a job. The IT industry were at its infancy, and the CS graduates were the pioneers who made it what it is today.

However, the industry is different today, and companies expectation changed too. As the industry matures, companies no longer need to settle for people with a general educational background (i.e. CS graduates) to learn and apply the technologies they require. Now, companies can choose people with EXACTLY the skills they need (i.e. J2EE, ASP.Net, PL/SQL, etc.), and can immediately work on projects and deliver results.

Unfortunately, traditional universities are slow when it comes to adapting to commercial needs, and the shift from mainly academic to commercial is what happened to programming. Therefore, alternatives are needed to satisfy market demands. Now, I'm only stating the realities of the IT industry and some ares of the software industry. I don't think this applies to other fields such as physics, economics, sociology, etc, where a traditional university education is still more suitable. The main point I'm trying to get across is that people who are interested in computers and programming today need to be more precise with their career goals, and choose the "right" education that will help them achieve their goals.
17 years ago
I think traditional universities should just eliminate the Bachelors and Masters degrees in Computer Science, and offer only a 10-year Ph.D. degree in CS. So, after graduating from high school, if your goal is to become a researcher/teacher in the theories of computing, then you would apply for the PhD program. If your goal is to get a job in the technology field, then you should apply for the more practical programs such as the one offered by North Face University. This way, it will be less confusing for the newbies fresh out of high school who mistakenly thinks that "B.Sc. in CS = job in IT", and the employers would get the right people with the practical skills they need.
17 years ago
I have no problem compiling that program. Maybe something is wrong with yout SDK?

Originally posted by Kitty Dayal:
Thanks for reply. But my question was related to duplication of objects in the pool. Since there is already a "abc" present, Will it not use it? Or Why does it not use it here?



The objects in the pool are used only in constant expressions or by calling the intern() method. Since x.concat("c") is calculated at runtime, objects in the pool are not used. Let me give you a few more examples:
Here are the correct comments for the code:

You can get the ServletContext of another web application by calling

getServletContext().getContext(uripath)

where uripath is the context path of the other web application. You can subsequently call getRequestDispatcher(path) on this context and forward the request to the appropriate resource on the second context.

Is this what you are trying to do?
17 years ago
I don't know why that wouldn't work. Perhaps you can achieve the same goal by mapping the url to a filter, and have the filter forward the request to your jsp page. Put something like this in your web.xml:

<filter>
<filter-name>TestFilter</filter-name>
<filter-class>TestFilter</filter-class>
</filter>
...
<filter-mapping>
<filter-name>TestFilter</filter-name>
<url-pattern>/folderB/*.jsp</url-pattern>
</filter-mapping>


And in the doFilter method of TestFilter, forward the request to the jsp page in folerA by calling request.getRequestDispatcher("/folderA/test.jsp").forward(request, response);

But I haven't tried it so I don't know if that actually works...
17 years ago
When casting double to byte, the value of the double is converted to an int first, and then from int to byte.

So, when you convert infinity to int, you get 0x7fffffff. When you convert 0x7fffffff to byte, you get 0xff, which is -1.

Originally posted by Kitty Dayal:
Hi Fletcher,

What about this? How many are created(objects) and where?

String a = new String( "abc" );
String b = a;
String c;
c = a + b;

This is from Bill's book, in which he say's 2 objects. One with the 'a' and the other with 'c'. He does not say anything about the object created in the pool. Should we count the object created in the pool? Obviously c refers a different object.

Thanks,
Kits



A String may or may not be created in the pool, depending on whether the pool already contains a String with the same value. Given the code you gave without any assumptions, you can only say for certain that 2 new String objects will be created.
Because unicode characters are translated before compile. So basically the code gets translated to the following before it's compiled:

As you can see, /u000a is literally translated in to a new line in the source code.
I agree that the answer should be b too. The concatenation a + b creates a temporary StringBuffer object, which in turn creates a new String object representing the result, and both are eligible for garbage collection.

Originally posted by Fletcher Estes:


The above code actually creates 3 String objects. The first object is "abc" and this is put in the String pool. The second and third objects are referred to by x and x1, with contents, but not references, equal to "abc"



Yes that's what I meant. Forgot that there was a string literal in the statement too