permaculture playing cards*
The moose likes Java in General and the fly likes Help needed! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help needed!" Watch "Help needed!" New topic
Author

Help needed!

Sundeep Malali
Greenhorn

Joined: Aug 20, 2003
Posts: 3
Hi,
I need help on the following:
1. How to implement a static variable without using the keyword 'static'.
2. Can you give me a scenario which neccesitates the use of only Inner classes to implement without using methods.
3. Is there any way to get a number in words by inputting the same in digits. For eg, if I input 18, it should return 'Eighteen'.
Thanks in advance.
Regds
Sundeep
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


1. How to implement a static variable without using the keyword 'static'.

Program in a language like Ruby that doesn't use this keyword to denote class variables?

2. Can you give me a scenario which neccesitates the use of only Inner classes to implement without using methods.

To implement what?

3. Is there any way to get a number in words by inputting the same in digits. For eg, if I input 18, it should return 'Eighteen'.

Yes, there is a way; you could write a Java program to do this.
Sorry, I don't mean to be rude, but these are clearly homework questions, and simply posting your homework here isn't considered good form. Lots of people here will be glad to help you figure these things out on your own, though.
I don't understand the first two questions; they're apparently trick questions which only students in the class might understand, based on something the instructor or textbook said. The third one, I can give you an idea of how to write it:
Imagine a HashMap where the keys are Integer objects and the values are String objects.
Start by putting in the Integer objects from zero to twenty. Now to print any of these in words, you just have to say
System.out.println(myMap.get(new Integer(theNumber));
Of course, this only works for those numbers you put in. Now, for other values, the rules are pretty regular. For the numbers from twenty-one to twenty-nine, you just print the word "twenty" followed by the result of following the first step for the value (theNumber - 20). The same for 31-39, 41-49, etc. So if you add the numbers 30, 40, 50, 60... to your table, then you can do the following to get you up to 99: if there's a value for the number in the table, print it, and you're done. Otherwise, take the number modulo ten, and print the value of looking up (theNumber - remainder) and the remainder itself.
Now, you need a rule to handle the values from 100 to 999. Then from 1000 to 9999. Then, you might look back and generalize what you've done...


[Jess in Action][AskingGoodQuestions]
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
How to implement a static variable without using the keyword 'static'.

You could declare an interface with a field. This is legal as interface fields are implicitly static (as well as implicitly public and final).
Note that it is bad design to use an interface just to declare constants.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed!
 
Similar Threads
CRC-32
Creating Linked List
AJAX without struts. Is it possible?
Global variables...
preventing multiple user with same user Name and pswd