Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

diff bet two methods  RSS feed

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between these definitions

public abstract void getData();
&
public abstract void getData(void);
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One will compile and one will not.
 
Java Cowboy
Sheriff
Posts: 16082
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only difference is that the first line compiles, and the second line does not. I tried it for you and it gave a compiler error:

Jesper.java:4: illegal start of type
public abstract void getData(void);
^

(note: the "^" points to "void", but the forum software eats up the spaces...).
[ September 05, 2005: Message edited by: Jesper de Jong ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jesper de Jong:
The only difference is that the first line compiles, and the second line does not. I tried it for you and it gave a compiler error:

Jesper.java:4: illegal start of type
public abstract void getData(void);
^

(note: the "^" points to "void", but the forum software eats up the spaces...).

[ September 05, 2005: Message edited by: Jesper de Jong ]



If you use UBB tags, you can force the software to preserve your spacing. In particular, either CODE or QUOTE tags will work.

Layne
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!