Vj Kamath

Greenhorn
+ Follow
since Nov 19, 2004
Merit badge: grant badges
For More
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 Vj Kamath

How about having a fish interface and animal interface. Then a amphibian interface that extends both fish and animal interfaces. And then a class which implements the amphibian interface ?
17 years ago
There is no clear definition of what an application server is.
In general an application server can create dynamic pages (and hence run an application) for the browser.
Tomcat has a servlet engine and can jun servlets and JSP. Hence it is not a simple web server like apache. But it is usually configured along with Apache.
It can be used to display the "state" of any object just before an exception occured. Just display the name and instance variable values in toString and use it in the catch block for an exception related to that object.
17 years ago
Here is some code to prove that there is a String pool that is returning the same reference for Strings with the same value.

17 years ago
Vinny wrote:

i do not have to show these records on the front end to the user,if i had to show the records, then probably pagination is the best approach,as you have suggested.
I have implemented pagination in my earlier projects,which involved front end .

Instead i have to generate a report(essentially write to a file and provide the file to the user)..
Also i am using a single thread to retrieve data.Also at anytime only one thread will be active for this.



You could use pagination for storing in the file as well. The concept is the same. You just retrieve a fixed set of records and write to the file(or report) and clearup the objects, then take the next set.

Advantage: You will used fixed amount of memory. Memory will not be dependant on the number of records you are retrieving

Disadvantage: You will have to make multiple calls to the database instead of one call. This may impact the response time for generating that report.
17 years ago
Aditya N Jha wrote:

In the first class, instantiation of the singleton instance is done inside the getInstance() method. This method is not synchronized. Hence, two different threads may access it simultaneously. In such a scenario, it is possible that the null-check and instantiation are done by both the threads. This will result in two instances of the class (or for that matter, theoritically, n instances for n number of threads).



As per my understanding, multiple Instances will NOT be created. There will be a new instance and the old instance will be garbage collected.

Note the code

and the code


The s will get the reference to the new Singleton object. The old object will get Garbage collected. Ofcourse this will defeat the purpose of Singleton as you rightly pointed out. But my point is that we won't have n instances for n number of threads. Please correct me if my understanding is incorrect.
17 years ago
You can implement multiple interfaces. But you cannot extend multiple classes.
17 years ago
One more thing to remember.
If you have the command prompt window BEFORE you set the PATH or CLASSPATH environment variable, then you will need to close and open the command prompt again.
17 years ago
Given this input, i have to write a program to generate different possible combinations.
( ( ( A | B | C | D | F | G | E | H | I ) & J ) | ( ( A | D | H ) & L ) | ( ( B | G ) & M ) | ( F & K ) )

result should be
AJ OR BJ OR CJ OR DJ OR EJ OR FJ OR HJ OR IJ
OR
AL OR DL OR HL
OR
BM OR GM
OR
FK

I have found programs that use stacks to convert from infix to postfix ...etc. But this program is different. This needs to resolve the string.
19 years ago
The purpose of an interface is to define only the structure but not the implementation of a class. This is used to define the WHAT and leave the HOW to the implementing class.
But an abstract class can have a partial implementation.
19 years ago
I assume you are refering to HashMap here.
You don't need to increment the key. You can keep adding (put) keys and values into the HashMap without worring about incrementing indexes.

You can get back the value you added using the get method
value=hm.get(key);
19 years ago
SMS are sent in the same way that mails are sent. All mobile numbers actually correspond to a email address.
For example:
If you want to sent an SMS to the cell phone with number 9845212345
which might be a Airtel Karnataka number, then you can send a mail to
9845212345@airtelkk.com

Similary if you want to send it to South Zone Hutch number say 9886454321
then send a mail to 9886454321@south.hutch.co.in

So what you need to do is find the corresponding email address of the number you want to send the SMS to.
Then use the simple mail APIs provided by Java to send the mail.
19 years ago
Include the wheel class in your slotmachine class.
19 years ago
Collections are used to store objects.
Some real world examples:

HashMap could be used to store key value pairs to load a dropdown box.
ArrayList could be used to store the data returned into a resultset from a database.
19 years ago
I assume you put number=6
Each element in your array is again an array of size 6. That could explain it.

You need to declare the array and its index outside your method which loads it. And increment the index inside your method
19 years ago