[ cyb / tech / λ / layer ] [ zzz / drg / lit / diy / art ] [ w / rpg / r ] [ q ] [ / ] [ popular / ???? / rules / radio / $$ / news ] [ volafile / uboa / sushi / LainTV / lewd ]

λ - programming

/lam/bda /lam/bda duck
Name
Email
Subject
Comment
File
Password (For file deletion.)

BUY LAINCHAN STICKERS HERE

STREAM » LainTV « STREAM

[Return][Go to bottom]

File: 1446493130721.jpeg (9.96 KB, 300x300, images.duckduckgo.com.jpeg) ImgOps iqdb

 No.11361

==Stupid / newbie question. (Bad english, sorry)==

Is there a way to automatically set an object variable as its instance name?

ex:

//Create instance
Pawn p1 = new Pawn("white");
System.out.println(p1.getName()); //Will print p1

-
Pawn is an abstract class of Pieces which has the var:
String name;
String color;

and Pawn's constructor atm is:
public Pawn(String color) {
super("", color);
}
>>

 No.11362

there's a beginner general, use the catalog pls <55

https://lainchan.org/λ/res/5683.html



Delete Post [ ]
[ cyb / tech / λ / layer ] [ zzz / drg / lit / diy / art ] [ w / rpg / r ] [ q ] [ / ] [ popular / ???? / rules / radio / $$ / news ] [ volafile / uboa / sushi / LainTV / lewd ]