Java Java Pointers and Missing method body

Click For Summary
The discussion highlights a common issue encountered by Java programmers regarding the use of pointers and method definitions. It clarifies that Java does not support pointers, which is why declaring a pointer as "char* ptr" leads to a compilation error. Additionally, it emphasizes that every method in Java must have a body, even if it's empty, which is necessary for the method to be valid. The conversation also notes that Java does not require function definitions in the same way as some other languages, suggesting that users should focus on correctly structuring their methods with the appropriate syntax, including the use of curly braces.
Pattielli
Messages
296
Reaction score
0
I declare my pointer as char* ptr and my function as public boolean FuncFoo() but java compiler complains that I have some problem with identifier right at * and my function is missing the method body...
I couldn't figure out what was wrong with them. Would you please help me ?
Thank you,
 
Technology news on Phys.org
Firts part: Java doesn't have pointers.

Second part
Code:
public boolean FuncFoo()
     {
          you need a body even if you leave it bank
     }

Java doesn't require function definitions either (is that why you're not using the {}?). Simply create your function and call it.

http://leepoint.net/notes-java/10background/10applications_and_applets/05intro/60JavaVsC.html
 
Last edited by a moderator:
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
5
Views
2K
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K