Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-14-2004, 02:09 AM   PM User | #1
WelshFlyer
New Coder

 
Join Date: Aug 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
WelshFlyer is an unknown quantity at this point
Java variable question

Bit of a newbie question:

All the online/manual and online tutorials explain how to initially assign something to a variable, but how do you change it when the program is running? In BASIC something like "if a$ = 2 then b$ = 3"

Also how can you take a string, say an input and assign it to a variable instead of using "system.out.println"

But how do you do this in JAVA? I'm not used to high level programming - BASIC is about as high level as I know.

Cheers,

Dave.

Last edited by WelshFlyer; 02-14-2004 at 02:11 AM..
WelshFlyer is offline   Reply With Quote
Old 02-16-2004, 11:22 PM   PM User | #2
sad69
Senior Coder

 
Join Date: Feb 2004
Posts: 1,206
Thanks: 0
Thanked 0 Times in 0 Posts
sad69 is an unknown quantity at this point
Java is about as high level as BASIC is, I think.

Java doesn't refer to variables with a $ in front.

For example:
Code:
 int a, b;
 a = 5;
 b = 3; 
 a = b + 2;
 b = 4;
The Java version of your BASIC code would be:
Code:
 if(a == 2)
  b = 3;
As far as strings go, Java has an object called String. Here are some examples with String:
Code:
 String a, b;
 a = "Hello";
 b = "World!";
 System.out.println(a+" "+b);
 String c = a+" "+b;
 System.out.println(c);
I'm not sure what else you need. There are plenty of tutorials online regarding this sort of stuff. I also think it would be good to look at some sample code programs and try to step through them and figure them out. Also, try to make changes to the programs and predict their effects. Then try to create your own sample programs using what you've learnt, and slowly reach your goal.

Try this site:
http://www.********************/java/index.php

Hope that helps,
Sadiq.
sad69 is offline   Reply With Quote
Old 02-17-2004, 01:09 AM   PM User | #3
WelshFlyer
New Coder

 
Join Date: Aug 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
WelshFlyer is an unknown quantity at this point
Thanks fot that - I'm using a novel way to learn JAVA - Knowing what I want to write (A program I need to develop for sombody) and trying to learn enough JAVA to do this.

But Seeing as JAVA is such a good language to learn, I'm going to keep expanding my knowledge, seeing as BASIC is obsolete.

Thanks for your help,

Dave.
WelshFlyer is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:40 PM.


Advertisement
Log in to turn off these ads.