Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25175 > unrolled thread

BlueJ Coding Help

Started byMarcelo Rodriguez <mrodvicente@gmail.com>
First post2013-08-30 17:30 -0700
Last post2013-09-02 13:53 +0200
Articles 9 — 5 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  BlueJ Coding Help Marcelo Rodriguez <mrodvicente@gmail.com> - 2013-08-30 17:30 -0700
    Re: BlueJ Coding Help Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-08-31 09:41 +0300
      Re: BlueJ Coding Help Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-08-31 11:26 -0400
      Re: BlueJ Coding Help Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-08-31 18:30 +0300
        Re: BlueJ Coding Help Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-09-01 02:20 +0200
          Re: BlueJ Coding Help Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-09-01 12:05 +0300
            Re: BlueJ Coding Help Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-09-01 15:47 +0200
              Re: BlueJ Coding Help Arne Vajhøj <arne@vajhoej.dk> - 2013-09-01 18:35 -0400
                Re: BlueJ Coding Help Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-09-02 13:53 +0200

#25175 — BlueJ Coding Help

FromMarcelo Rodriguez <mrodvicente@gmail.com>
Date2013-08-30 17:30 -0700
SubjectBlueJ Coding Help
Message-ID<87e3fd5b-cd93-4c50-bef4-05d9cf49ab0f@googlegroups.com>
I started my first day with Computer Science (Learning Java with BlueJ) and I'm not quite sure how to explain this, so here's what I am trying to end up with (the part in the middle of the dashes):

----------------------------------------
From: Bill Smith
Address: Dell Computer, Bldg 13
Date: April 12, 2005

To: Jack Jones

Message: Help! I'm trapped inside a computer!

-----------------------------------------

The order of the code that I am typing is 
------------------------------------

//Author: Me
//Date created: Mar 22, 2005
public class Tester
{
public static void main(String args[])
{
System.out.println("From: Bill Smith\n");
}
----------------------------------

I am not quite sure if this is the correct format to start with or where exactly the "\n" goes or if I need it at all or if I need the "ln" after "print".
Any help is really appreciated and I'm sorry I can't explain this too well..

[toc] | [next] | [standalone]


#25178

FromJukka Lahtinen <jtfjdehf@hotmail.com.invalid>
Date2013-08-31 09:41 +0300
Message-ID<lveh9a2whi.fsf@saunalahti.fi>
In reply to#25175
Marcelo Rodriguez <mrodvicente@gmail.com> writes:

> System.out.println("From: Bill Smith\n");

That way you'll end up with double line breaks between linies.
The method System.out.println always adds a linefeed at the end of the
output, and you add one yourself with the \n.

> I am not quite sure if this is the correct format to start with or where
> exactly the "\n" goes or if I need it at all or if I need the "ln" after
> "print".

If you don't want double line breaks, either remove the \n or replace
the pirntln method with print.

-- 
Jukka Lahtinen

[toc] | [prev] | [next] | [standalone]


#25181

FromEric Sosman <esosman@comcast-dot-net.invalid>
Date2013-08-31 11:26 -0400
Message-ID<kvt1vl$cj5$1@dont-email.me>
In reply to#25178
On 8/31/2013 9:46 AM, Stefan Ram wrote:
> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>> The method System.out.println always adds a linefeed
>
>    the system's line separator
>
>>                                                      at the end of the
>> output, and you add one yourself with the \n.
>
>    "\n" might not be the system's line separator.

     Is it just me, or are others also peeved that PrintStream
always ends lines with the system's line separator?  IMHO, the
separator should be choosable on a stream-by-stream basis, so
(for example) one could easily write through a PrintStream to
a socket protocol requiring \r\n no matter what the local
system uses.

     Ah, well.  The horse and barn have been nonproximate for
a long time now.

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

[toc] | [prev] | [next] | [standalone]


#25182

FromJukka Lahtinen <jtfjdehf@hotmail.com.invalid>
Date2013-08-31 18:30 +0300
Message-ID<lva9jxubc8.fsf@saunalahti.fi>
In reply to#25178
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>>The method System.out.println always adds a linefeed 

>   the system's line separator

>>                                                     at the end of the
>>output, and you add one yourself with the \n.

>   "\n" might not be the system's line separator.

True, but is there a system where it doesn't cause a linefeed?
For example, in the MS systems where the normal line separator is \r\n,
a lone \n moves the cursor to the next line. And when the println method
ends the output with \r\n, the cursor ends up at the beginning of the
next line after that. It doesn't really matter that there was no
carriage return before the first linefeed.

-- 
Jukka Lahtinen

[toc] | [prev] | [next] | [standalone]


#25184

FromDaniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Date2013-09-01 02:20 +0200
Message-ID<kvu18t$dsj$1@dont-email.me>
In reply to#25182
On 2013-08-31 17:30, Jukka Lahtinen allegedly wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>>> The method System.out.println always adds a linefeed 
> 
>>   the system's line separator
> 
>>>                                                     at the end of the
>>> output, and you add one yourself with the \n.
> 
>>   "\n" might not be the system's line separator.
> 
> True, but is there a system where it doesn't cause a linefeed?
> For example, in the MS systems where the normal line separator is \r\n,
> a lone \n moves the cursor to the next line. And when the println method
> ends the output with \r\n, the cursor ends up at the beginning of the
> next line after that. It doesn't really matter that there was no
> carriage return before the first linefeed.

Macintoshes, pre-OS X if I'm not mistaken, used \r (carriage return) as
the line separator.

[toc] | [prev] | [next] | [standalone]


#25190

FromJukka Lahtinen <jtfjdehf@hotmail.com.invalid>
Date2013-09-01 12:05 +0300
Message-ID<lveh98lxnd.fsf@saunalahti.fi>
In reply to#25184
Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> writes:
> On 2013-08-31 17:30, Jukka Lahtinen allegedly wrote:
>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>>>> The method System.out.println always adds a linefeed 
>>>> at the end of the
>>>> output, and you add one yourself with the \n.

>>>   "\n" might not be the system's line separator.

>> True, but is there a system where it doesn't cause a linefeed?

> Macintoshes, pre-OS X if I'm not mistaken, used \r (carriage return) as
> the line separator.

I thought they use LF and CR (in that order, opposite to the DOS world),
not only the CR. I never used them myself, don't they do anything with
just a LF that doesn't come with CR?

-- 
Jukka Lahtinen

[toc] | [prev] | [next] | [standalone]


#25193

FromDaniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Date2013-09-01 15:47 +0200
Message-ID<kvvgi0$bd5$1@dont-email.me>
In reply to#25190
On 2013-09-01 11:05, Jukka Lahtinen allegedly wrote:
> Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> writes:
>> On 2013-08-31 17:30, Jukka Lahtinen allegedly wrote:
>>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>>> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>>>>> The method System.out.println always adds a linefeed 
>>>>> at the end of the
>>>>> output, and you add one yourself with the \n.
> 
>>>>   "\n" might not be the system's line separator.
> 
>>> True, but is there a system where it doesn't cause a linefeed?
> 
>> Macintoshes, pre-OS X if I'm not mistaken, used \r (carriage return) as
>> the line separator.
> 
> I thought they use LF and CR (in that order, opposite to the DOS world),
> not only the CR. I never used them myself, don't they do anything with
> just a LF that doesn't come with CR?

No, just the carriage return.

I do not know what they would have done with a line feed, sorry. For my
practical purposes, MacOS has always been ancient history (as opposed to
OSX, which uses LF).

They just use the carriage return. It's one of those things you just
pick up. Because whenever the geeks ramble, like old cow-boys around the
fire, multiple parallel soliloquies, and one of them ever-so-slightly
implicitly associates the EOL sequence with a LF character, you'll
invariably have one of the thither silent ones jump up and interject:
"Tut tut tut, LF might /not be/ the line separator", in an ominous tone.
And then the one who made the association falls silent, for he knows he
has sinned; and then all the greenhorns perk up, ravished by this new
mysterious development; and they press the old hands with questions, to
pierce the mystery. A satisfied smile settles on the faces of the old
hands, and after a little pressing (etiquette obliges), they will go
into lively discussions about ye olden days (discussions which might
actually, but not necessarily, address the mystery at hand)... which I'd
personally love to do, 'cause it's fun and it's knowledge, but can't, so
I'm just giving you the meta.

[toc] | [prev] | [next] | [standalone]


#25204

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-09-01 18:35 -0400
Message-ID<5223c151$0$298$14726298@news.sunsite.dk>
In reply to#25193
On 9/1/2013 9:47 AM, Daniele Futtorovic wrote:
> On 2013-09-01 11:05, Jukka Lahtinen allegedly wrote:
>> Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> writes:
>>> On 2013-08-31 17:30, Jukka Lahtinen allegedly wrote:
>>>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>>>> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>>>>>> The method System.out.println always adds a linefeed
>>>>>> at the end of the
>>>>>> output, and you add one yourself with the \n.
>>
>>>>>    "\n" might not be the system's line separator.
>>
>>>> True, but is there a system where it doesn't cause a linefeed?
>>
>>> Macintoshes, pre-OS X if I'm not mistaken, used \r (carriage return) as
>>> the line separator.
>>
>> I thought they use LF and CR (in that order, opposite to the DOS world),
>> not only the CR. I never used them myself, don't they do anything with
>> just a LF that doesn't come with CR?
>
> No, just the carriage return.
>
> I do not know what they would have done with a line feed, sorry. For my
> practical purposes, MacOS has always been ancient history (as opposed to
> OSX, which uses LF).
>
> They just use the carriage return. It's one of those things you just
> pick up. Because whenever the geeks ramble, like old cow-boys around the
> fire, multiple parallel soliloquies, and one of them ever-so-slightly
> implicitly associates the EOL sequence with a LF character, you'll
> invariably have one of the thither silent ones jump up and interject:
> "Tut tut tut, LF might /not be/ the line separator", in an ominous tone.
> And then the one who made the association falls silent, for he knows he
> has sinned; and then all the greenhorns perk up, ravished by this new
> mysterious development; and they press the old hands with questions, to
> pierce the mystery. A satisfied smile settles on the faces of the old
> hands, and after a little pressing (etiquette obliges), they will go
> into lively discussions about ye olden days (discussions which might
> actually, but not necessarily, address the mystery at hand)... which I'd
> personally love to do, 'cause it's fun and it's knowledge, but can't, so
> I'm just giving you the meta.

I think that description is rather accurate.

But I still think that it is relevant to bring it up.

There are certain things about portability that developers
should learn at some point.

LF terminated, CRLF terminated, CR terminated, count prefix,
count prefix & suffix variable length line formats.

Little and big endian.

IEEE floating point and other floating point formats.

Unicode, UTF-8, UTF-16, ISO-8859-1, ASCII, EBCDIC for text.

Etc.

Arne


[toc] | [prev] | [next] | [standalone]


#25209

FromDaniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Date2013-09-02 13:53 +0200
Message-ID<l01u84$roi$1@dont-email.me>
In reply to#25204
On 2013-09-02 00:35, Arne Vajhøj allegedly wrote:
> On 9/1/2013 9:47 AM, Daniele Futtorovic wrote:
>> On 2013-09-01 11:05, Jukka Lahtinen allegedly wrote:
>>> Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> writes:
>>>> On 2013-08-31 17:30, Jukka Lahtinen allegedly wrote:
>>>>> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>>>>> Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> writes:
>>>>>>> The method System.out.println always adds a linefeed
>>>>>>> at the end of the
>>>>>>> output, and you add one yourself with the \n.
>>>
>>>>>>    "\n" might not be the system's line separator.
>>>
>>>>> True, but is there a system where it doesn't cause a linefeed?
>>>
>>>> Macintoshes, pre-OS X if I'm not mistaken, used \r (carriage return) as
>>>> the line separator.
>>>
>>> I thought they use LF and CR (in that order, opposite to the DOS world),
>>> not only the CR. I never used them myself, don't they do anything with
>>> just a LF that doesn't come with CR?
>>
>> No, just the carriage return.
>>
>> I do not know what they would have done with a line feed, sorry. For my
>> practical purposes, MacOS has always been ancient history (as opposed to
>> OSX, which uses LF).
>>
>> They just use the carriage return. It's one of those things you just
>> pick up. Because whenever the geeks ramble, like old cow-boys around the
>> fire, multiple parallel soliloquies, and one of them ever-so-slightly
>> implicitly associates the EOL sequence with a LF character, you'll
>> invariably have one of the thither silent ones jump up and interject:
>> "Tut tut tut, LF might /not be/ the line separator", in an ominous tone.
>> And then the one who made the association falls silent, for he knows he
>> has sinned; and then all the greenhorns perk up, ravished by this new
>> mysterious development; and they press the old hands with questions, to
>> pierce the mystery. A satisfied smile settles on the faces of the old
>> hands, and after a little pressing (etiquette obliges), they will go
>> into lively discussions about ye olden days (discussions which might
>> actually, but not necessarily, address the mystery at hand)... which I'd
>> personally love to do, 'cause it's fun and it's knowledge, but can't, so
>> I'm just giving you the meta.
> 
> I think that description is rather accurate.
> 
> But I still think that it is relevant to bring it up.
> 
> There are certain things about portability that developers
> should learn at some point.
> 
> LF terminated, CRLF terminated, CR terminated, count prefix,
> count prefix & suffix variable length line formats.
> 
> Little and big endian.
> 
> IEEE floating point and other floating point formats.
> 
> Unicode, UTF-8, UTF-16, ISO-8859-1, ASCII, EBCDIC for text.
> 
> Etc.

In case it wasn't clear from the above: wholeheartedly agreed, and I
love those discussions, and was just frustrated by my inability to do it
myself. :)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web