File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Passing arguments in multiple lines Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Passing arguments in multiple lines" Watch "Passing arguments in multiple lines" New topic
Author

Passing arguments in multiple lines

Nich Aquilina
Greenhorn

Joined: Feb 05, 2007
Posts: 6
Hi,

Is there any way to split code in more than one line? to avoid scrolling? This especiallyin constructor, for example:-

Worker(String name, String firstName, String dateOfBirth, String........)

Thanks
Nich
John Bartlett
Ranch Hand

Joined: Jan 25, 2006
Posts: 116
I am not entirely sure what you mean by this, but if you mean just to avoid horizontal scrolling then why not just put the next param on a new line?

e.g.



although if you mean knowing that you are going to be receiving multiple params of the same type, i.e. above, and you want to reduce the code, then couldnt you use a varargs e.g.



Not sure if that is what you wanted but hope it helps,

John
[ February 06, 2007: Message edited by: John Bartlett ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Java doesn't distinguish between new lines and other white space (outside of comments and String literals). That is, everywhere you can use a space character, you can also use a new line. Both of the following code snippets are totally valid Java code:





Both aren't styles I would recommend, though...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Nich Aquilina
Greenhorn

Joined: Feb 05, 2007
Posts: 6
Thanks guys, that was it. Not the extreme one but worked great.

ManualWorker(String familyName,
String firstName,
String dateOfBirth,
String employeeNumber,
String dateOfFirstEmployment,
Nich Aquilina
Greenhorn

Joined: Feb 05, 2007
Posts: 6
Thanks guys, that was it. worked great.

ManualWorker(String familyName,
String firstName, String dateOfBirth, String employeeNumber,
String dateOfFirstEmployment)

Nicholas
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Passing arguments in multiple lines
 
Similar Threads
How to convert byte array into string array?
date format with MS Access database
Tech Word Game
WA #1.....word association
ResultSet to Array