Thomas White

Ranch Hand
+ Follow
since Feb 01, 2003
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 Thomas White

Kashif,
That function is hilarious.

[ January 26, 2005: Message edited by: Thomas White ]
16 years ago
I'm all for the semi-nude models on the front page. That something TOI should keep!
17 years ago
Obviously there are plenty of well qualified programmers in India. I think one thing this article may imply is that to be economically viable, India needs to focus on its own infrastructure, develope its own companies involved in R&D, move towards first world status, improving standards of living for the general population, and becoming economic player on the world scene.
This is not to single out India. I think it implies to the world scene in general. When American CEO's run around the world looking for the cheapest programmers it might make the annual stock report look a little better but it doesn't help the American economy in the long run. Enrollment in engineering and computer science programs in the U.S. is already dropping. That means less creative minds fueling R&D in the U.S ultimately hurting our status in the world stage. Same goes for India. If you continue to rely on American corporations for your future eventually you'll get burned. They'll find cheaper programmers somewhere else. Whereas if both countries protect their internal investments we all prosper in the long term.
Thomas
[ April 28, 2004: Message edited by: Thomas White ]
17 years ago
JNI
Hello Everyone,
I have JNI problem pertaining to a C++ file compilation.
Let me start with what I have:
I have a java program Timex.java that implements JNI:

I also have the header file Timex.h:

and I have the .cpp file time_clock.cpp:

I compiled the java program file, create the .h file fine, then I go to compile time_clock using the following commands:
g++ -fpic -I c:\j2sdk1.4.1_03\include
-I c:\j2sdk1.4.1_03\include\win32
time_clock.cpp
I get a long list of error messages not pertaining to time_clock.cpp but pertaining to the code in jni.h and jni_md.h. I've never tampered with these files. Could they have gotten messed up some how, could they be deprecated? I'm confused. Any help would be greatly appreciated.
Thanks,
Thomas
17 years ago
Hi Jim,
I want to do the latter; measure how much time has elapsed using the system time. However, I have been told that System.currentTimeMillis()does not measure exactly how much cpu time is taken up by running the program. My questions pertain specifically to a homework assignment I have listed as follows:

Write a small java method that sums up an array of ints and throws an exception if the sum is odd. If the sum is even return true. In the catch clause for the exception return false. Run timing studies to show the real cost of the exception. For example, call the method a million times for each possible return value, and report the aggregate CPU time for all the runs returning false and for those returning true.


I wrote the method. I just trying to find out how to get the cpu time for each call.
17 years ago

Jini, did you say? ...Or did you mean JNDI?


No, I said JNI, Java Native Interface.
http://java.sun.com/j2se/1.4.2/docs/guide/jni/
Thomas
17 years ago
Hello All,
Is there anyone out there with knowledge about how to do cpu timing for a java program? I've heard it can be done using jni. I just don't know how to approach it. Any help would be greatly appreciated.
Thanks,
Thomas
[ January 29, 2004: Message edited by: Thomas White ]
17 years ago
Here's a link from an article by Dr. Andrew Weil, seems balanced.
www.drweil.com
He says the cancer/mult.sclerosis claims on the internet are unfounded, but does mention other risks and ultimately recommends using sugar in moderation over artificial sweeteners.
[ November 06, 2003: Message edited by: Thomas White ]
17 years ago

[ November 05, 2003: Message edited by: Thomas White ]
17 years ago

it's no surprise to find government buildings overrun with monkeys.


No, it's not a suprise, sounds like the White House.
17 years ago
Dirk and Eugene,
Thanks for both your excellent examples. Eugene, I think your last example comes closest to addressing the problem from Scott's book.
The JLS states:

A private class member or constructor is accessible only within the class body in which the member is declared and is not inherited by subclasses.


Yet with reflection we have an example in the Java API where you can violate the language specification on private level access and get away with it.
Thanks for all your examples,
Thomas
18 years ago
Hi Eugene,
Thanks, thats a great example
18 years ago
Chandra,
Its ok for the end user to see the values of i,s and j. Thats not a violation of the concept of private and protected variables. The idea is that you declare variables private if you do not want a class other than the class they reside in to be able to access and manipulate them. You declare a variable protected if you only want classes of the same package or subclasses of that particular class to access you variable, but not classes that are outside the package and not subclasses. Since your
print() method is protected, it allows package level classes and subclasses of your base class to call it, and thus the private variables i and s(along with j) are printed, but the variables are still private. Class Derive cannot directly access them. For example you cannot say
"super.i = 54;" in Derived because i is private, you also cannot say in Derived "System.out.println(super.i);". But you can use your print() method to print the values because the method has protected access.
Now as far as variable j is concerned, Derived can access this variable directly because it is protected, so you could say "super.j = 101;" for example to change the variable(*note: you can't however do this in you main method of Derive because super.j is not a static variable).
As far as your question about declaring variables separately, I'm not sure what you mean but the way you have them
"....
private int i;
private String s;
protected int j;
..."
is fine.
Thomas
[ September 12, 2003: Message edited by: Thomas White ]
[ September 12, 2003: Message edited by: Thomas White ]
[ September 12, 2003: Message edited by: Thomas White ]
18 years ago
Hey Don and Ernest
Thanks for the examples. Don are you saying that writing a catch block with no code to handle the exception might be considered a flaw in the language spec?
18 years ago
Chandra,
Your derived class can call the print() method of the base class and thus the values of i and s are printed to the console, but that does not violate the concept of private variables. The derived class cannot access i and j directly and thus cannot change them. You want to make fields private when you don't want another class to have direct access to them (and therefore possibly changing them in unwanted ways), however, as often is the case, the protected print() method in your base class allows subclasses and classes of the same package to use i and j (in this case print their values to standard output) without modifying them.
Also,in case its not clear, because int j is protected, classes of the same package as the base class and subclasses outside of its package can access and modify j directly.
[ September 12, 2003: Message edited by: Thomas White ]
[ September 12, 2003: Message edited by: Thomas White ]
18 years ago