Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

variables and methods  RSS feed

 
Tim Tock
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi can someone help a greenhorn,
I have two files, in one file im just trying to make this statement work
start = myAddress.GotoAddress();
in other file in my myAddress file i have a method that is simply
public char GotoAddress()
{
return myAddress;
}
I dont understand as this statement works fine
System.out.println(myAddress.GotoAddress());
so why not
start = myAddress.GotoAddress();
Any help would be appreciated
T
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
It would work fine if "start" were a previously-declared variable of type int or char, and if the line appeared inside a method (as opposed to just inside the body of a class.) So, for example,

Note that there's a strongly established convention that method names in Java start with a lower-case letter; "GotoAddress" violates this convention, making your code a bit harder to read.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!