Skip to content

Commit 64ec242

Browse files
Update java017.md
1 parent 043e0be commit 64ec242

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

JavaLesson017/java017.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,45 @@ enum Color {
18051805
}
18061806
}
18071807
```
1808-
### enum sınıfına eklenen ctor elemanı ve her bir sabite iliştirilen bilgi!
1808+
### enum sınıfına eklenen ctor elemanına göre nesne yaratılması durumu
1809+
```java
1810+
/*----------------------------------------------------------------------------------------------------------------------
1811+
Aşağıdaki örnekte Color enum sınıfında altı tane nesne yaratılır. Farklı constructor ile ilişkilendirilen farklı
1812+
nesneler yaratılır. Herhangi bir atama söz konusu değildir!
1813+
----------------------------------------------------------------------------------------------------------------------*/
1814+
package org.csystem.app;
1815+
1816+
class App {
1817+
public static void main(String [] args)
1818+
{
1819+
Color color1 = Color.BLUE;
1820+
Color color2 = Color.B;
1821+
1822+
System.out.printf("color1 == color2");
1823+
}
1824+
}
1825+
1826+
enum Color {
1827+
RED(255, 0, 0), GREEN(0, 255, 0), BLUE(0, 0, 255),
1828+
R(RED), G(GREEN), B(BLUE);
1829+
public final int r, b, g;
1830+
1831+
Color(int x, int y, int z)
1832+
{
1833+
r = x;
1834+
g = y;
1835+
b = z;
1836+
}
1837+
1838+
Color(Color c)
1839+
{
1840+
r = c.r;
1841+
g = c.g;
1842+
b = c.b;
1843+
}
1844+
}
1845+
```
1846+
### enum class ile Singleton sınıf bildirimi.
18091847
```java
18101848
/*----------------------------------------------------------------------------------------------------------------------
18111849
Aşağıdaki örnekte Color enum sınıfına eklenen ctor elemanı ile her bir sabite ilişkin nesneye bilgi iliştirilmiştir

0 commit comments

Comments
 (0)