i have error: illegal start of expression
can you help me ??

public void AddBefor(int befor,int a)
	{
		if(head!=null)
		{
			if(head.value==befor)
			{
				IntDLLNode t=new IntDLLNode(a);
				t.next=head;
				head.preve=t;
				t.preve=null;
				head=t;
			}
			else
			{
				IntDLLNode t;
				for(t=head;t!=null;&& t.value!=befor;t=t.next);
				if(t!=null)
				{
					IntDLLNode t1=new IntDLLNode(a);
					t1.next=t;
					t1.preve=t.preve;
					t.preve=t;
					t.preve.next=t;
				}
			}
		}
	}

Recommended Answers

All 4 Replies

Full error message please: it shows which line and where on that line

the error is in this line number 16

for(t=head;t!=null;&& t.value!=befor;t=t.next);

You aren't following the for-loop format...
for(initial; upper bound; step)

You have initial correct but not your upper bound. Get rid of ";" before && and see what happen.

PS: You shouldn't use "for" loop in this case. You should use "while" loop instead...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.