Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > please help understanding syntax

Reply
Thread Tools

please help understanding syntax

 
 
John Goche
Guest
Posts: n/a
 
      01-07-2012

Hello,

I am looking at the java code on the following page:

http://gnuc.in/resources/archives/1404

There I find the following, but I do not
understand the syntax Auth.background() { ... }

public void checkAccount(final Account account)
{
Auth.background()
{
@Override
public void run()
{
Auth.checkAccount(account, this, new CustomCallback()
{
@Override
public void handle(int resultCode)
{
// ...
}
});
}
});
}

Can someone please explain the syntax Auth.background() { ... } .
I understand the rest of the syntax.

Thanks,

John Goche
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      01-07-2012
On Sat, 7 Jan 2012 13:15:43 -0800 (PST), John Goche
<(E-Mail Removed)> wrote, quoted or indirectly quoted
someone who said :

>Can someone please explain the syntax Auth.background() { ... } .
>I understand the rest of the syntax.


see http://mindprod.com/jgloss/anonymousclasses.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
If you can't remember the name of some method,
consider changing it to something you can remember.

 
Reply With Quote
 
 
 
 
Steven Simpson
Guest
Posts: n/a
 
      01-07-2012
On 07/01/12 21:15, John Goche wrote:
> public void checkAccount(final Account account)
> {
> Auth.background()
> {
> @Override
> public void run()
> {
> Auth.checkAccount(account, this, new CustomCallback()
> {
> @Override
> public void handle(int resultCode)
> {
> // ...
> }
> });
> }
> });
> }
>
> Can someone please explain the syntax Auth.background() { ... } .


It's a syntax error, surely? Try sticking it in a syntax-aware editor
with a 'class X { }' around it. When I add the closing brace in emacs,
I'm told "Mismatched parentheses".

Perhaps it's supposed to be 'new Auth.background()', though that's an
unconventional name for a class.

Perhaps it's supposed to be 'new Auth.background(new Runnable() { ...'.

....

--
ss at comp dot lancs dot ac dot uk

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      01-08-2012
Steven Simpson wrote:
> John Goche wrote:
>> public void checkAccount(final Account account)
>> {
>> Auth.background()
>> {
>> @Override
>> public void run()
>> {
>> Auth.checkAccount(account, this, new CustomCallback()
>> {
>> @Override
>> public void handle(int resultCode)
>> {
>> // ...
>> }
>> });
>> }
>> });
>> }
>>
>> Can someone please explain the syntax Auth.background() { ... } .

>
> It's a syntax error, surely? Try sticking it in a syntax-aware editor with a
> 'class X { }' around it. When I add the closing brace in emacs, I'm told
> "Mismatched parentheses".
>
> Perhaps it's supposed to be 'new Auth.background()', though that's an
> unconventional name for a class.
>
> Perhaps it's supposed to be 'new Auth.background(new Runnable() { ...'.
>
> ...


Whatever it's supposed to be, the code at that site is not compilable, nor
does the author even provide complete classes. It is evidence that mere
presence on the Web does not make for good information.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
Steven Simpson
Guest
Posts: n/a
 
      01-08-2012
On 07/01/12 22:55, Steven Simpson wrote:
> Perhaps it's supposed to be 'new Auth.background()', though that's an
> unconventional name for a class.
>
> Perhaps it's supposed to be 'new Auth.background(new Runnable() { ...'.


D'oh! For the Runnable case, I meant 'Auth.background(new Runnable()
{...'. Too many 'new's. Not that the extra 'new' was necessarily
wrong, just not intended.


--
ss at comp dot lancs dot ac dot uk

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      01-16-2012
On Sat, 07 Jan 2012 22:55:55 +0000, Steven Simpson <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>It's a syntax error, surely? Try sticking it in a syntax-aware editor
>with a 'class X { }' around it. When I add the closing brace in emacs,
>I'm told "Mismatched parentheses".


for samples of anonymous classes that will compile, see
http://mindprod.com/jgloss/anonymousclasses.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
One of the most useful comments you can put in a program is
"If you change this, remember to change ?XXX? too".

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help understanding javascript syntax MG Javascript 4 04-14-2010 04:15 PM
Please Help in understanding a VHDL syntax buddy249 VHDL 1 06-23-2009 11:55 AM
please help, understanding RJB valid syntax scootiePuff Ruby 0 04-03-2008 06:40 PM
Help understanding Scheme's syntax, procedures and calls Fran Python 12 08-14-2004 03:32 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments