LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2004, 04:37 AM   #16
khtse
Member
 
Registered: Sep 2003
Location: Hong Kong
Distribution: Slackware 9.1
Posts: 43

Rep: Reputation: 15

As the previous poster correctly said, you do not use quotes for assigning values to integers. Quotes are used for Strings...

Corrected code should be :

class Hello {
public static void main (String[] args) {
int minute, hour;
minute = 59;
hour = 11;
System.out.print ("The time is ");
System.out.print (hour);
System.out.print (":");
System.out.print (minute);
System.out.print (".");
}
}
 
Old 02-04-2004, 08:24 AM   #17
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Rep: Reputation: 15
if you want to declare an int don't use " ", as that defines a string. It will work though, java converts int to string automatically in this case
 
Old 02-04-2004, 08:46 AM   #18
doakster
LQ Newbie
 
Registered: Jan 2004
Location: The Mighty Miramichi River
Distribution: Red Hat 9.0
Posts: 12

Rep: Reputation: 0
Nic-MDKman was right. You don't need the double quotes for an integer, double, float, etc. Double quotes are only used for strings. Also, you don't need a new print statement for each segment, you can combine them as follows:

System.out.print ("The time is ", hour, ":", minute, ".");

Also, System.out.println can be used and will automatically append a new line character ('\n') to the end of the string.
Personally, I've done a fair amount of programming in Java, and I found the only thing it is useful for is it's easy to program GUIs with it. Other than that, I far prefer C. But hey, thats just my opinion. If you like it, have fun.

Matthew Doak
 
Old 02-04-2004, 11:14 AM   #19
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
<edited>

Last edited by moeminhtun; 02-04-2004 at 11:16 AM.
 
Old 02-04-2004, 06:36 PM   #20
cyborg_jt
Member
 
Registered: Jan 2004
Location: New Zealand
Distribution: 2.6.11-gentoo-r3
Posts: 120

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by doakster
N
System.out.print ("The time is ", hour, ":", minute, ".");
Tried this but it says
cannot resolve symbol -method print (java.lang.String,int,java.lang.String,int,java.lang.String)
 
Old 02-04-2004, 06:42 PM   #21
Looking_Lost
Senior Member
 
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
System.out.print ("The time is "+ hour+ ":"+minute+ ".");
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming in Linux alexgsummer Programming 35 03-29-2005 09:03 AM
programming with java in linux? newbieX Linux - Newbie 9 12-30-2003 06:39 AM
Programming java in linux heming Linux - Software 4 02-28-2003 02:40 PM
Java programming in linux heming Linux - Newbie 4 02-28-2003 08:34 AM
Java programming in linux heming Linux - General 3 02-28-2003 08:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration