Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

question about what a method does

Thread view: 
--+--Raven--+-- - 05 May 2004 07:20 GMT
I am working on a lab for my college that tells you to take a number and
reverse it and then add them and repeat until you get a palindrome number.
I am horrible at Java, but I am getting close to a solution.  My question
is, while I was looking on the internet for ideas, I ran across the
Integer.parseInt() method.   I was wondering if anyone could just simply
tell me what this method does.  I would include my code, but it is kind of
unnecessary, plus, I don't want anyone to think that I am trying to get my
labs done for free!

R
Andrew Thompson - 05 May 2004 07:41 GMT
> ...Integer.parseInt() method.  
> I was wondering if anyone could just simply
> tell me what this method does.

Tell an OP the answer and she(/he) codes for a day,
show her(/him) the JavaDocs and she(/he) codes for life..
<http://www.physci.org/api.jsp?class=java.lang.Integer>

HTH

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology

Roedy Green - 05 May 2004 20:59 GMT
>My question
>is, while I was looking on the internet for ideas, I ran across the
>Integer.parseInt() method.   I was wondering if anyone could just simply
>tell me what this method does.

see http://mindprod.com/converter.html

Why not try the experiment?

Your computer will not explode no matter what parameters you feed it.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
--+--Raven--+-- - 05 May 2004 22:23 GMT
> >My question
> >is, while I was looking on the internet for ideas, I ran across the
[quoted text clipped - 6 lines]
>
> Your computer will not explode no matter what parameters you feed it.

The reason I don't experiment is because as I am not good at all with Java,
so I don't even know what to do with the method, for that matter, I don't
even know what I am doing!.  I cannot program at all, for some reason it
just doesn't make sense to me and my classes are all correspondence which
makes it harder since I am basically the teacher.  So, I don't even have the
code complete, and very far from it I imagine.   Basically I am trying to
muddle through this course and get it done and put it behind me so that I
never have to look at Java (or any programming) again!

R
Roedy Green - 05 May 2004 22:54 GMT
>The reason I don't experiment is because as I am not good at all with Java,

You got it backwards. The reason you are not good at all with Java is
you don't experiment.  The only way to learn is to perform
experiments.

The people who write about these things, myself included, are
generally not that good at explaining.  Some experiments will clarify
much better than 1000 more words.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Roedy Green - 05 May 2004 22:56 GMT
> I cannot program at all, for some reason it
>just doesn't make sense to me and my classes are all correspondence which
>makes it harder since I am basically the teacher.  So, I don't even have the
>code complete, and very far from it I imagine.

Start with the simplest programs, like HelloWorld, and you gradually
add to them.  If it does not work, you know where the trouble lies.

Another approach is to find exlsting working programs that are vaguely
similar to what you want, and change only a line, and see what
happens.  Gradually inch you way toward what you want.

It seems overwhelming to start, but pretty soon, you will wonder what
the fuss was about.  It all seems so obvious, you will wonder why it
did not make sense before.

See also http://mindprod.com/jgloss/gettingstarted.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
--+--Raven--+-- - 06 May 2004 02:49 GMT
> Start with the simplest programs, like HelloWorld, and you gradually
> add to them.  If it does not work, you know where the trouble lies.
[quoted text clipped - 8 lines]
>
> See also http://mindprod.com/jgloss/gettingstarted.html

Thanks for the words of advice.  Tonight, I will be going back to the
drawing board and start at square 1 to see what I missed (I just wish I had
more time to work on my course and before I get out of the military!)

The biggest problem I am having right now is figuring out how to get a
program to add two strings (of numbers) together until it comes up with a
palindrome, so I think that is why I am getting so frustrated, but I don't
want anyone to tell me, because I would like to have the satisfaction of
creating the program, but the pointing me in the right direction (i.e.
Tutorials) is very appreciative!

R
Joe - 06 May 2004 04:58 GMT
> The biggest problem I am having right now is figuring out how to get a
> program to add two strings (of numbers) together until it comes up with a
> palindrome,

That sounds kinda fun actually.

Are you trying to come up with something like:
AB + BA = CDDC

You've got a good start with the Integer class. I think the StringBuffer
class will come in handy as well.

The tricky part I guess is writing a method that determines if a string
is a palindrome

private boolean isPalindrome(String CDDC) {

    if ((reverse the first half ) == (second half )) {
        return true;
    }
    else {
        return false;
    }   
}

If you're stuck, forget all about Java and write it out in English how
you would tell a complete idiot to do it, step-by-step.
Roedy Green - 06 May 2004 06:23 GMT
>The biggest problem I am having right now is figuring out how to get a
>program to add two strings (of numbers) together until it comes up with a
>palindrome, so I think that is why I am getting so frustrated, but I don't
>want anyone to tell me, because I would like to have the satisfaction of
>creating the program, but the pointing me in the right direction (i.e.
>Tutorials) is very appreciative!

Break the problem into pieces

write a method

public boolean isPalindrome( String s )

You can test it with strings you make up.

See http://mindprod.com/jgloss/combinations.html
for techniques for generating all possible combinations of things.

I gather raw material is a list of words, you glue 2 to 3 together and
see if you get a palindrome.  You could just generate random
combinations.  See http://mindprod.com/jgloss/randomnumbers.html.

Your list of words could be a String[] or an ArrayList.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
--+--Raven--+-- - 06 May 2004 06:56 GMT
"Roedy Green" wrote in message ...
> Break the problem into pieces
>
[quoted text clipped - 12 lines]
>
> Your list of words could be a String[] or an ArrayList.

Thank you all for the suggestions, and I have actually formulated a little
bit of code that reasonably seems like it will work, and now I am testing it
to see if it will.  I also sent it up to my instructor, as they can often
point you in the right direction (as far as page number and reference to
what they want).  Right now though, I am just calmly running through my code
and fixing and tweaking to get the operation I need.

After writing what I wanted to do in English, I was able to start putting
this together, so thank you for that suggestion (Joe) and for the website.

R
Tom - 06 May 2004 14:16 GMT
> I am working on a lab for my college that tells you to take a number and
> reverse it and then add them and repeat until you get a palindrome number.
[quoted text clipped - 6 lines]
>
> R
It doesn't appear that your original question has been answered, so
let me start there.  Then please indulge me and read the rest of the
post.

The method that you ask about will read a String object, and if it
contains characters that represent a numerical value, it will return
that value in the form of an int.  For example, the following will
store the number 12,345 in the variable number.  "12345" is NOT a
number.  It is a string of characters.

int number = Integer.parseInt("12345");

When/if you get to the point in your class where you are learning how
to input data into a program that is running, the input is always done
in Strings.  Imagine that you had to write a program that was supposed
to ask someone for their age and then determine if they were old
enough to drive.  When they entered in their age, you would would get
that data as a String object, say "21".  But you can't compare letters
to numbers, so the parseInt method can convert the letters in the
String to a number that you can compare to the legal driving age.

OK, I hope that makes some sense to you.  Now, let me get on the
soapbox for a minute.  Andrew gave you a link to the documentation for
the method that you requested.  Here is another link that will take
you to the documentation for ALL of the classes that come with Java
(version 1.4.2)
http://java.sun.com/j2se/1.4.2/docs/api/

You can learn a ton by reading through this.  There are examples,
links to a tutorial, links to sample code.  This is a very valuable
resource.

Roedy gave you links to his glossary, which is another valuable
resource.  His page also has a ton of links to other resources, such
as FAQ's (answers to Frequently Asked Questions).  Explore this too.

Lastly, let me suggest that you download a copy of DrJava
(drjava.sourceforge.net).  This is a lightweight editor created by the
folks at Rice University.  It is an excellent tool that has been
designed for beginners, not experienced programmers.  It contains an
interactions pane where you can enter in lines of code, without having
to write entire programs, run them and see immediate results.  Great
for experimenting.  And its FREE!!  And open-source!!  And written in
Java!!  And it will walk your dog!! (No, I don't think that last one
is correct.)

Disclaimer, I have made a small contribution to the DrJava project - I
designed the basis for the DrJava logo - but I do not stand to gain in
any way by promoting it, and I am not affiliated with the project or
Rice University.
javac - 06 May 2004 23:25 GMT
using net beans, it has a little help gizmo.

first you type "java." really quickly, and a little box'll pop up.
then press delete until "java." is completely erased and type whatever
you want, and the appropiate box'll pop up.

there should be a way to work it without the "java." to start off, but
it never works for me...

btw, anyone know how to access these little explanation-box things in
a more readable way?

also, that parseInt cracks me up, it's _such_ a PITA saver :)

javac@mail.com
http://www.geocities.com/cjavacjava/
Christophe Vanfleteren - 07 May 2004 00:06 GMT
> using net beans, it has a little help gizmo.
>
[quoted text clipped - 9 lines]
>
> also, that parseInt cracks me up, it's _such_ a PITA saver :)

ctrl-space should do the trick.
And you can set the size of the inline javadoc in the options.

Signature

Kind regards,
Christophe Vanfleteren

Andrew Thompson - 07 May 2004 02:48 GMT
...
> Here is another link that will take
> you to the documentation for ALL of the classes that come with Java
> (version 1.4.2)
> http://java.sun.com/j2se/1.4.2/docs/api/

That is a great link Tom.  [ What would we do without them??  ]

But I think this is _also_ a valuable one..
<http://java.sun.com/j2se/1.4.2/docs/api/overview-summary.html>

This leads you to the non-frames 'package index'
of ..exactly the same document.  That allows you to
surf down through the packages to your class and
method, and it also includes a link back to the
'frames' based version you mentioned.

If you know what you are looking for, the second
link is much quicker (especially in bandwidth!)
while *your* link brings up the full index ..allowing
you to 'wallow' in the classes, or to find _every/_any_
class by name in the long index on the lower left.

Signature

Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.