please help understanding syntax

J

John Goche

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
 
S

Steven Simpson

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() { ...'.

....
 
L

Lew

Steven 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".

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.
 
S

Steven Simpson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top