i dont know whats wrong with this program...the compiler compiles the program but when i run it it shows:
johnrambo@ubuntu:~/Desktop$ java lora
Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:443)
at lunda.l2read(lora.java:24)
at lora.main(lora.java:124)

class lunda{


	String[] la=new String[2048];
	String[] lb=new String[2048];
	int[] lvalid_a=new int[2048];
	int[] lvalid_b=new int[2048];
	int[] lage_a=new int[2048];
	int[] lage_b=new int[2048];
	int lhit=0;
	int lmiss=0;
	String s1;
	String s2;
	int lindex;
	String ls1;
	String ls2;
	
	String ruba;
	public String l2read(String s)
	{
		String ls1=s.substring(0,14);
		String ls2=s.substring(14,25);
		int lindex=Integer.parseInt(s2,2);


		for(int i=0;i<2048;i++)
		{
			lvalid_a[i]=0;                                                  //initialising array ot 0//
			lvalid_b[i]=0;
		}


		if(lvalid_a[lindex]==0&& lvalid_b[lindex]==0)
		{
			la[lindex]=ls1;

			lvalid_a[lindex]=1;
			lage_a[lindex]=1;
			String ruba="0";

		}
		if(lvalid_a[lindex]==0&& lvalid_b[lindex]==1)
		{
			if(ls1==lb[lindex])
			{
				lage_b[lindex]++;
				String ruba="1";

			}	
			else
			{
				la[lindex]=s1;

				lvalid_a[lindex]=1;
				String ruba="0";

			}
		}
		if(lvalid_a[lindex]==0&& lvalid_b[lindex]==1)
		{
			if(ls1==la[lindex])
			{
				lage_a[lindex]++;
				String ruba="1";

			}	
			else
			{
				lb[lindex]=s1;	

				lvalid_b[lindex]++;
				String ruba="0";

			}
		}

		if(lvalid_a[lindex]==1&&lvalid_b[lindex]==1)
		{
		
		if(ls1==la[lindex])
		{
			lage_a[lindex]++;
			String ruba="1";

		}	

		else if(ls1==lb[lindex])
		{
			lage_b[lindex]++;
			String ruba="1";

		}

		else
		{

			if(lage_a[lindex]>=lage_b[lindex])
			{
				la[lindex]=ls1;
				lage_a[lindex]=1;
				lage_b[lindex]++;
			}
			else
			{
				lb[lindex]=s1;
				lage_b[lindex]=1;
				lage_a[lindex]++;
			}
				String ruba="0";
		}
		}

		return ruba;
	}
	}
	public class lora
{
	public static void main(String[] args) throws Exception
	{
		String s;
		s="10101010101000000011111001100111";
		lunda x=new lunda();
		String g=x.l2read(s);
		System.out.println(g);
	}
}

Recommended Answers

All 5 Replies

according the error message you're trying to parse a null-value (a variable in which you haven't stored a value yet) into an integer.

you 've stored a value in ls2, not in s2, which you are trying to parse.

At line 23, your s2 variable is null.

At line 23, your s2 variable is null.

and ... how is this post adding anything?

ohhhh such a silly mistake on my side. thanks for your help.:)

and ... how is this post adding anything?

my post was late by 2 minutes, hope you understand =.=

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.