Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Permenkaret Permenkaret is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 351
Rep Power: 14
Permenkaret mempunyai hidup yang Normal
Default [ask help] error di java : cannot find symbol

Agan2 master java, mohon bantuannya yah ...



Ane lagi belajar polymorphisme dalam java nih Gan, berikut kode programnya :




Code:

class bentuk
{
public void gambar()
{
System.out.println("menggambar");
}
public void hapus()
{
System.out.println("menghapus gambar");
}
}

class lingkaran extends bentuk
{
public void gambar()
{
System.out.println("menggambar lingkaran");
}
public void hapus()
{
System.out.println("menghapus lingkaran ");
}
}
class elips extends bentuk
{
public void gambar()
{
System.out.println("menggambar elips");
}
public void hapus()
{
System.out.println("menghapus elips");
}
}
class segitiga extends bentuk
{
public void gambar()
{
System.out.println("menggambar segitiga");
}
public void hapus()
{
System.out.println("menghapus segitiga");
}
}
class Random
{
private Random rand = new Random();
public bentuk next()

{
switch(rand.nextInt(3))
{
default:
case 0:return new lingkaran();
case 1:return new elips();
case 2:return new segitiga();
}

}
}
public class latihan3a
{
private static Random gen = new Random();
public static void main(String[]args)
{
bentuk[]bangun= new bentuk[3];
for(int i=0;ilatihan3a.java:54: cannot find symbol
symbol : method nextInt(int)
location: class Random
switch(rand.nextInt(3))
^
1 error

Ane udah ngutak - ngatik tu sintaks, kaga nemu juga Gan...



Tolong bantu ya Gan ...



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 03:44 PM.


no new posts