0

In this code I create a Node class:

   public class Node
    {
   private String data;
    private Node next;
//
public void setData(String s)
{
data = s;
}
public Strinf getData()
{
return data;
}
//
public  void setNext(Node n)
{
next = n;
}
public Node getNext()
{
return next;
}

and I using of this class in below class:

public class A
{
   public int countFunc(String s)
   {
       return s.length();
    }
}

public Main extends Activity
{
   ...
     Node n = new Node();
     n.setNext(null);
     n.setData("A");
     A objA = new A();
     int i = objA.countFunc(n.getData());
   ...
}

After that run application, the application has been show:

Unfortunately,Main has been Stopped

but when I use it in Toast,for example:

Toast.makeText(this, n.getData(), Toast.LENGTH_LONG).show();

no error has been show! and run successfully! How i do? thanks.

oop12
  • 17
  • 5
  • 2
    You need to post the stacktrace of the crash so we can help...always post the stacktrace of a crash – codeMagic Apr 12 '15 at 02:15
  • Thanks,what is the stacktrace? – oop12 Apr 12 '15 at 03:10
  • See [this post](http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors) and [this one](http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – codeMagic Apr 12 '15 at 03:13
  • 1
    have look in to this may its helps :) https://github.com/orhanobut/hawk – MilapTank Apr 12 '15 at 03:37
  • Thanks,but not help!!! – oop12 Apr 12 '15 at 03:44
  • 2
    You need to read the posts I suggested, learn about the stacktrace, and post that so we can know what/where the error is. "Unfortunately,Main has been Stopped" is a generic error message simply telling you there *is* a problem but not *what* the problem is. – codeMagic Apr 12 '15 at 03:48

0 Answers0