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


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

New Java 8 syntax?

Started byKnute Johnson <nospam@rabbitbrush.frazmtn.com>
First post2015-01-30 21:18 -0800
Last post2015-01-31 09:34 -0800
Articles 5 — 3 participants

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


Contents

  New Java 8 syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-01-30 21:18 -0800
    Re: New Java 8 syntax? Arne Vajhøj <arne@vajhoej.dk> - 2015-01-31 08:25 -0500
      Re: New Java 8 syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-01-31 09:32 -0800
    Re: New Java 8 syntax? Jeff Higgins <jeff@invalid.invalid> - 2015-01-31 12:25 -0500
      Re: New Java 8 syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-01-31 09:34 -0800

#30957 — New Java 8 syntax?

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2015-01-30 21:18 -0800
SubjectNew Java 8 syntax?
Message-ID<mahohs$tuh$1@dont-email.me>
So I thought that the ; was optional if you had only one statement but 
it won't compile.  If you have a block then the ;s are required.

public class test {
     public static void main(String... args) {

         new Thread(() -> System.out.println("hello world!") ).start();

         new Thread(() -> { System.out.println("goodbye"); } ).start();
     }
}

I bought a pretty good book, Java 8 Lambdas by Richard Warburton.

Thanks,

knute...

[toc] | [next] | [standalone]


#30960

FromArne Vajhøj <arne@vajhoej.dk>
Date2015-01-31 08:25 -0500
Message-ID<54ccd7df$0$288$14726298@news.sunsite.dk>
In reply to#30957
On 1/31/2015 12:18 AM, Knute Johnson wrote:
> So I thought that the ; was optional if you had only one statement but
> it won't compile.  If you have a block then the ;s are required.
>
> public class test {
>      public static void main(String... args) {
>
>          new Thread(() -> System.out.println("hello world!") ).start();
>
>          new Thread(() -> { System.out.println("goodbye"); } ).start();
>      }
> }
>
> I bought a pretty good book, Java 8 Lambdas by Richard Warburton.

The code above builds fine with both Oracle JDK and Eclipse compiler
here.

Arne

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


#30962

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2015-01-31 09:32 -0800
Message-ID<maj3hv$b8l$1@dont-email.me>
In reply to#30960
On 1/31/2015 05:25, Arne Vajhøj wrote:
> On 1/31/2015 12:18 AM, Knute Johnson wrote:
>> So I thought that the ; was optional if you had only one statement but
>> it won't compile.  If you have a block then the ;s are required.
>>
>> public class test {
>>      public static void main(String... args) {
>>
>>          new Thread(() -> System.out.println("hello world!") ).start();
>>
>>          new Thread(() -> { System.out.println("goodbye"); } ).start();
>>      }
>> }
>>
>> I bought a pretty good book, Java 8 Lambdas by Richard Warburton.
>
> The code above builds fine with both Oracle JDK and Eclipse compiler
> here.
>
> Arne
>
>

OK, I wasn't clear again.  I thought that in the statement

   new Thread(() -> System.out.println("hello world!") ).start();

the semicolon after the System.out.println("hello world!"); was 
optional?  Meaning that

   new Thread(() -> System.out.println("hello world!"); ).start();

would compile.  Not that leaving off the semicolon was required.

k...

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


#30961

FromJeff Higgins <jeff@invalid.invalid>
Date2015-01-31 12:25 -0500
Message-ID<maj3cg$alo$1@dont-email.me>
In reply to#30957
On 01/31/2015 12:18 AM, Knute Johnson wrote:
> So I thought that the ; was optional if you had only one statement but
> it won't compile.  If you have a block then the ;s are required.
>
> public class test {
>      public static void main(String... args) {
>
>          new Thread(() -> System.out.println("hello world!") ).start();
>
>          new Thread(() -> { System.out.println("goodbye"); } ).start();
            JLS 8 - 14.8 ExpressionStatement
            Certain kinds of expressions may be used as statements by
            following them with semicolons.
            I don't see any diffs thereabouts in the
            "PDF with diffs from Java SE 7 Edition"

>      }
> }
>
> I bought a pretty good book, Java 8 Lambdas by Richard Warburton.

I have a small collection (~3 or 4) of  O'Reilly books that I keep
fairly handy and a much larger collection of one readers gathering dust.
Will Java 8 Lambdas become a reference or dust collector?

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


#30963

FromKnute Johnson <nospam@rabbitbrush.frazmtn.com>
Date2015-01-31 09:34 -0800
Message-ID<maj3l7$b8l$2@dont-email.me>
In reply to#30961
On 1/31/2015 09:25, Jeff Higgins wrote:
>> I bought a pretty good book, Java 8 Lambdas by Richard Warburton.
>
> I have a small collection (~3 or 4) of  O'Reilly books that I keep
> fairly handy and a much larger collection of one readers gathering dust.
> Will Java 8 Lambdas become a reference or dust collector?

I have a large collection of dusters that were once definite readers. 
Time will tell on this one.

k...

[toc] | [prev] | [standalone]


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


csiph-web