how do i de define keyword

i want to define keywords like the #define in c++ because ts is better than this
11 Replies
JavaBot
JavaBot7d ago
This post has been reserved for your question.
Hey @handsome asian! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
straightface
straightface7d ago
you cant in java
treegus
treegus7d ago
well, you can do like that just use
public static final int MAX_NUMBER = 5
public static final int MAX_NUMBER = 5
but you can't define methods.
JavaBot
JavaBot7d ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
nib
nibOP6d ago
no single way?
treegus
treegus6d ago
well, There is lambda method. I can't know you want this.
public static final Function<String, String> GREET = name -> "Hello, " + name + "!";
public static final Function<String, String> GREET = name -> "Hello, " + name + "!";
It is lambda
nib
nibOP6d ago
i mean keyword "this" to "ts" just like #define in c++
treegus
treegus6d ago
just use
public static final String ts = "this"
public static final String ts = "this"
I can't know perfectly. I think making "this"(String) to "ts"(String) maybe cant
JavaBot
JavaBot6d ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
nib
nibOP5d ago
no, this, this.pissedMeOff()
JavaBot
JavaBot5d ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?