I'm trying to assign a different value for each actor to the variable "file" in example class using its object in class A.
class A{
var a1=new Array[example](2)
def starting()= {
for(i <- 0 to 3){
if(i==0){
a1(i).file="L1.txt";
}
else if(i==1){
a1(i).file="L2.txt";
}
a1(i).start
}
}
}
class example extends Actor {
var file="default.txt"
var Handle = new A
def act()= {
loop{
var count=0
react{
//remaining code
}
}
}
This is throwing a nullpointerexception corresponding to the lines :
for(i <- 0 to 3){
if(i==0){
a1(i).file="L1.txt";
}
i'm a beginner in scala.. i somehow am unable to figure out the reason for this exception. Please help.