PDA

View Full Version : Java, the language!


Mat_guy
10-16-2006, 03:08 PM
Hey, I started a computer programming course this year, and we are basing it on the language of JAVA. I'm wondering if any of you know a fair amount aobu tthe language because I'm finding it confusing, a lot. I am using JCreator to compile and build any script I write. And it would be a giant plus if you could; if you can, help me program with JAVA. :joo: :thumbsup:

Wolf Pup TK
10-16-2006, 03:34 PM
I recommend downloading Eclipse. It's beautiful, seriously. It compiles as you code, highlights errors, links packages and stuff for you. It's just awesome.

I'm bad with linking libraries and stuff, but if you have code related questions, I can probably help you out.

Mat_guy
10-16-2006, 10:48 PM
I recommend downloading Eclipse. It's beautiful, seriously. It compiles as you code, highlights errors, links packages and stuff for you. It's just awesome.

I'm bad with linking libraries and stuff, but if you have code related questions, I can probably help you out.
Thanks for the heads up on Eclipse, but it would not do much help for me seeing as my CPRO 12 (Computer Programming) teacher has installed JCreator on all of the Tech ED computers already and that is what he has us using, but it deffinatly would be a big help for code tips. Right now we have a problem that we had to make into a flowchart. This is what I made for the flowchart, with a few more forwarding information points. (http://img201.imageshack.us/my.php?image=caloriecalculatorra6.jpg)
I have to make that into a JAVA program using an ouput and input as a regular "Windows" console, ""JOptionPane"". Do you know anytihng about what I'm going at Wolf Pup TK?

Wolf Pup TK
10-17-2006, 04:15 AM
Thanks for the heads up on Eclipse, but it would not do much help for me seeing as my CPRO 12 (Computer Programming) teacher has installed JCreator on all of the Tech ED computers already and that is what he has us using, but it deffinatly would be a big help for code tips. Right now we have a problem that we had to make into a flowchart. This is what I made for the flowchart, with a few more forwarding information points. (http://img201.imageshack.us/my.php?image=caloriecalculatorra6.jpg)
I have to make that into a JAVA program using an ouput and input as a regular "Windows" console, ""JOptionPane"". Do you know anytihng about what I'm going at Wolf Pup TK?
Your teacher tells you to use $ in variable names? *slaps forehead*

variableOne, variableTwo, soGoesTheNamingConvention
ClassesLikeThis

Anyway, I haven't worked with JOptionPanes myself, but looking at the javadocs (please, PLEASE tell me your teacher told you about javadocs (http://java.sun.com/j2se/1.4.2/docs/api/)), you can find all the info you need able the capabilities of a class.

So over here (http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JOptionPane.html) we have the JOptionPane. It looks like you should take a look at showInputDialog(). You might need to cast the Object it returns to a string, but if you're not familiar with casting, I'd ask your teacher about it to make sure you're on the right track.

Good luck! =3

Magnus9
10-17-2006, 04:59 AM
Ya, $ bad. Listen to Wolfpup, he's pointing you in the right direction. Just remember you can't use operators on Strings. ;)

Wolf Pup TK
10-17-2006, 05:14 AM
Thank goodness Java has methods to easily convert strings to integers and such. (Although you actually can use some operators on strings: stringX + stringY is the concatenation of the two)

Magnus9
10-17-2006, 05:35 AM
...duh, I forgot about concatenation.

Speaking of strings, if you have the time try to add in a little error check to make sure people can only enter integers. CIS professors love to break beginner's programs like these by typing in letters where you're asking for integers.

Ted the Penguin
10-17-2006, 10:19 AM
the java api is online, and fully searchable, lets you find out what all of those little functions you call do, and good for finding one to do something, when you dont know what its called. so I guess your teacher likes perl, which is fine, perl rocks for scripting, hell some big name companies in industry use perl for alot of their backend scripts. but yeah, once you learn to program the hardest thing is learning syntax, so you dont have to go lookup all the simple functions all the time.

Mat_guy
10-17-2006, 07:38 PM
Your teacher tells you to use $ in variable names? *slaps forehead*

variableOne, variab............... =3
No, my teacher didn't teach me to us $ in variable names, i just use it in making flowcharts to verify the variables easier and so if someone else is to make a program out of my flowchart, they can find them faster. And yes he has showed us the docs, except we use lke version 1.5.2 or something like that.

Mat_guy
10-17-2006, 07:39 PM
...duh, I forgot about concatenation.

Speaking of strings, if you have the time try to add in a little error check to make sure people can only enter integers. CIS professors love to break beginner's programs like these by typing in letters where you're asking for integers.
Yea, concatenation is HUGELY inportant and I will get to the error check once I'm able to get the easier things running, because I'm having a hard time understanding the language for the moment.

Mat_guy
10-17-2006, 07:41 PM
the java api is online, and fully searchable, ....
Yes, it is searchable, but I still had a hard time incorporating that into my program because I wasn't understanding what they meant.

Quiksilver
10-17-2006, 10:20 PM
What exactly are you making with java anyway? or Did you say it all ready, cause i just kinda skimmed through it.

Ted the Penguin
10-18-2006, 09:21 AM
he is making a basic program that runs from the command line, reads some numbers does some math and prints the result. it is not java specific or anything, just that his class is using java to teach basic programming.

you wont need to really use the online API until you get to some higher level stuff, right now all you need to do is get the syntax right.

wait until you get to an OS and network class where you have to design a file system, including creating a file table format, THAT was fun.

BioRebel
10-18-2006, 11:07 AM
Gah! I hate Java, C++ is so much better. Java has WAY too many useless features, which is why every Java text book is so friggin massive.

Mat_guy
10-21-2006, 12:42 AM
Gah! I hate Java, C++ is so much better. Java has WAY too many useless features, which is why every Java text book is so friggin massive.
I completely agree with you, except I have not programmed in C++ and JAVA is the only prgram I have done any with. And my teacher knows a local University Prof. that teaches JAVA and well, he made a textbook, and we are using it for beta teaching style, BIG MISTAKE, whoever this Prof. is, I don't even think he knows what JAVA is other than another word for coffee.

Also, Ted, the API is helping me because I am a complete noob at JAVA right now so whenever I can't get someone in my class that knows whats going on, I need something, and also, what mostly I need is the pure basics, like you said, syntax, which I'm having a really hard time with right now, but then also getting into using JOptionPane, which I've made some progress with, because from now on, the programs we build, will have to output into a Windows Console, instead of CMD format.

echoes
10-21-2006, 01:53 AM
guys I'm having a problem here - what is the name of the error you get in C++ when you try to access an array item that doesn't exist? I've had this memory literally a hundred times but I can't remember it

Wolf Pup TK
10-21-2006, 03:48 AM
guys I'm having a problem here - what is the name of the error you get in C++ when you try to access an array item that doesn't exist? I've had this memory literally a hundred times but I can't remember it
I can't tell if you're serious or not, or is this a jest about the lack of any useful information when you get an error in C++?

The error is called something along the lines of "array index out of bounds", but in C++ it will most likely just segfault and crash. In java you'll get a clean error message.

Guys, I wouldn't bash java so much, it's got LOTS of nice features. I really like java because it does so many things for you that C and C++ ignore. Try parsing a file in C++, or dealing with linking errors, or dealing with errors period. Java usually exits cleanly and gives nice error messages. C++ just dies and/or explodes.

Overall, the flexibility of C++ rocks, but there's a definate price to pay for it. Of course, there are several applications where Java is 100% suitable.


EDIT: Another thing that is infinately better in java. DOCUMENTATION. Seriously, C++ documentation is some of the worst ever. Often it's just not there. In java there is TONS of documented code. It's so indredibly easy to use new packages and stuff in Java. If only it were better for programming games I'd be using it all the time.

echoes
10-21-2006, 03:55 AM
segmentation fault was the phrase I was looking for. Thanks. I had genuinely forgoten the name of that damn error

Wolf Pup TK
10-21-2006, 04:03 AM
segmentation fault was the phrase I was looking for. Thanks. I had genuinely forgoten the name of that damn error
I could never forget given how many times I've caused one...
Hehe, anyway, glad to be of service!

Mat_guy
10-21-2006, 09:47 AM
I'm just wondering about this, should I edit the title of the thread to just "Programming Languages" so we can talk about them all?

chazbot
10-23-2006, 12:54 AM
im too old to use C++, just plain C. i use cobol, fortran. even assembly. i don't think they teach those anymore.

Ted the Penguin
10-23-2006, 12:38 PM
mips assembly is still taught, just had a class using it a year or two ago, as for cobol and fortran I dont think so, but I did have to use some fortran code for some image processing work I did on one of my coops

HotPuppy
10-23-2006, 12:41 PM
im too old to use C++, just plain C. i use cobol, fortran. even assembly. i don't think they teach those anymore.
They still teach fortran here actually and they're going to remove cobol next semester and we still have pascal also, it's considered a good beginner language.

GuyQuest
10-24-2006, 05:27 AM
Guys, I wouldn't bash java so much, it's got LOTS of nice features. I really like java because it does so many things for you that C and C++ ignore. Try parsing a file in C++, or dealing with linking errors, or dealing with errors period. Java usually exits cleanly and gives nice error messages. C++ just dies and/or explodes.

Overall, the flexibility of C++ rocks, but there's a definate price to pay for it. Of course, there are several applications where Java is 100% suitable.


EDIT: Another thing that is infinately better in java. DOCUMENTATION. Seriously, C++ documentation is some of the worst ever. Often it's just not there. In java there is TONS of documented code. It's so indredibly easy to use new packages and stuff in Java. If only it were better for programming games I'd be using it all the time.
Don't forget about Java's lovely self controlled garbage collector.

You want to free up some space? Sorry, that object is still referenced by an object that is referenced by an object that has a reference to it buried in your program, and the .finalize() method does nothing!

I remember someone saying it best, "If I were to go back in time and help Sun make Java, I would do one thing. Get rid of finalize and replace it with public void kill(). One call from anywhere and BAM!".

Mat_guy
11-01-2006, 11:36 PM
I really need help right now, I just cannot seem to improve still. I have 2 problems.

1.
Write a program that will ask for a number called "n" and will print out the first "n" numbers of the Fibonacci series

(Fib series is where, as below, 1 + 2 = 3, 2 + 3 = 4, 3 + 4 = 7, etc.
1 1
2 3
3 5
4 7
5 9
6 11

2.
Write a program that will print all the factors of a number that is entered in an input box. If there are no factors other than 1 and itself, it will printout "the number is prime".

Now if anyone is nice enough :iffy: to help me, I don't want you to do it, I just need help getting the calculation right. Most of you can probably figure it out simple, but I need to be able to make it into a cup of coffee :lol: .

echoes
11-01-2006, 11:52 PM
1.
x= 0
sum = 1
while (int x < n)
sum += n
x = sum;

approximately

Quiksilver
11-02-2006, 02:35 PM
Sounds like you jsut did someones homework xD

echoes
11-05-2006, 02:56 PM
ooops

I think I screwed up in there.

Styrak
11-17-2006, 02:21 AM
Hey. I just joined the forums, and I'm also taking a Java programming class. However, I've used Java a lot before, and can probably help out if need be. Oh, also, that error message is "Segmentation fault (Core dumped)".