LinuxQuestions.org
Visit Jeremy's Blog.
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 01-26-2004, 02:45 AM   #1
Dominik
Member
 
Registered: Nov 2003
Distribution: slackware9.1/freebsd5.2
Posts: 53

Rep: Reputation: 15
Question why does my P.print method work ?


Hi,

I'v started with java.

Recently I'v written a print method ;

public class P{

public static void print(String wrd){
System.out.println(wrd);
}
}

I've used it by mistake in a P.print("hello" + f) where f is a float and it worked.

I tried with more ... + ... + ... in the () & it was ok too.

I don't understand why. "hello" + f is not a string input for the print() method.

I replaced the String by String[] in the print method input declaration and it doesn't work. (i thought String[] was the most general entry form as it is used in
the main method).

Can someone explain me why?

thanks.
 
Old 01-26-2004, 03:11 AM   #2
UltimaGuy
Member
 
Registered: Aug 2003
Location: Chennai, India
Distribution: PCLinuxOS .92, FC4
Posts: 840

Rep: Reputation: 32
When you give a string + any data type ( like "test" + float or "one" + int ), java will automatically convert the other data type and concatenate it into the string!

This is one of the advantages in Java. And String[] points to an array and will only work if you pass an array, instead of a single String!
 
  


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
Method Not Allowed: The requested method POST is not allowed for the URL /writedhcp.p WiWa Linux - Networking 15 01-06-2011 01:20 PM
input method doesn't work sometimes NeoAnderson Debian 0 10-01-2005 06:57 AM
Print screen doesn't work mysticsound Linux - Laptop and Netbook 1 03-17-2005 09:24 AM
My printer does not work after I print a document rangerssg Linux - Hardware 3 08-29-2004 06:13 PM
Mozilla problems: Print/print preview doesn't work, not recording sites in history... andy_g_gray Linux - Software 3 01-23-2004 06:27 AM

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

All times are GMT -5. The time now is 12:37 PM.

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