Java Tips

ElijahLofgren

I follow Jesus Christ, enjoy helping people, and like making websites. Who is Jesus?

Jesus gives me overflowing hope, peace, and joy in this short life of mine. You can have it too! :)

My life mission: "Whatever you do, do it all for the glory of God." - 1 Corinthians 10:31

You are here: Home » Java Tips

Java Tips

Contents

Avoid typing in user input every time you run your program

Modified: 2007-04-23 23:21:12

From #letu on irc.freenode.net:

22:12 < SirAlaran> Tip of the day:
22:12 < SirAlaran> To avoid typing in user input every time you run your
                   program, you can do something like this:
22:12 < SirAlaran> echo "csedegree.prj" | java Main
22:17 < SirAlaran> There's a better way though.
22:17 < SirAlaran> Stick all your sample input in a text file.
22:17 < SirAlaran> java Main < testFile.txt

This tip was originally from Dr. Baas.

Convert a double to an int

Modified: 2007-04-26 21:56:03

If x is a double variable, just cast it to an int like this:
 (int)x

Example Java Applet with GUI Buttons

Modified: 2007-04-27 13:49:48

Here is the applet version of the last program I wrote for Computer Science 2: Graph Lines. I've also made the code available..

Comments

Comments? Questions? What do you think?

Add A Comment

Type in the letters/numbers in the picture below (spam prevention measure):

2 + 4 =
Your Name(*):
Comment(*):

Current Comments

  • On June 15, 2008, 1:02 pm Elijah Lofgren said...

    Hi S. Allen,

    Installing the &quot;sub-java6-plugin&quot; package should work with Firefox on Kubuntu Hardy.

    I hope this helps,

    Elijah

  • On June 10, 2008, 7:02 pm S. Allen said...

    Is there any way to get Java to work with Kubuntu? I have installed, uninstalled too many times. The Java test thinks its good, yet I can run no Java apps whatsoever. Appreciate your opinion.

Last Modified: July 1, 2008 09:53 PM

Back to Top

Previous page: NXT Tips

Next page: Tutorials