I have one activity one tab with fragment . But it keeps giving me the error &quot;java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference&quot;. Send data to fragment: final DescriptionDetailFragment ddf = new DescriptionDetailFragment();  Bundle bundleddf =new Bundle();         bundleddf.putString(&quot;description&quot;, massageModel.getDescription());         ddf.setArguments(bundleddf);  Called activity: desc = v.findViewById(R.id.description);          Bundle b1 =getArguments();          String description = b1.getString(&quot;description&quot;);          desc.setText(description);  Can someone help me out why this is happening?
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
53765
When I parse my xml file (variable f) in this method, I get an error      C:\Documents and Settings\joe\Desktop\aicpcudev\OnlineModule\map.dtd (The system cannot find the path specified)   I know I do not have the dtd, nor do I need it.  How can I parse this File object into a Document object while ignoring DTD reference errors?  private static Document getDoc(File f, String docId) throws Exception{     DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();     DocumentBuilder db = dbf.newDocumentBuilder();     Document doc = db.parse(f);       return doc; }
58610
This is a follow-up to .     When I click a link to an SE site in the Android app, it gives me an "open with" pop-up that has two options:         Chrome   Stack Exchange         I can then choose to open SE posts like this "Just once" or "Always."      The problem is that when I set the SE app to "always," and I click "open in browser,"   Except, the app crashes when trying to open it in browser.  LogCat (just right after selecting "Open in browser")  01-22 18:03:36.354: E/AndroidRuntime(16064): FATAL EXCEPTION: main 01-22 18:03:36.354: E/AndroidRuntime(16064): Process: com.stackexchange.marvin, PID: 16064 01-22 18:03:36.354: E/AndroidRuntime(16064): java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.stackexchange.marvin.utils.Helpers.getNonMarvinViewIntent(Helpers.java:452) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.stackexchange.marvin.ui.question.QuestionDialog$1.onClick(QuestionDialog.java:39) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1108) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AdapterView.performItemClick(AdapterView.java:310) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AbsListView.performItemClick(AbsListView.java:1145) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3066) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.widget.AbsListView$3.run(AbsListView.java:3903) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.os.Handler.handleCallback(Handler.java:739) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.os.Handler.dispatchMessage(Handler.java:95) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.os.Looper.loop(Looper.java:148) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at android.app.ActivityThread.main(ActivityThread.java:5417) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at java.lang.reflect.Method.invoke(Native Method) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 01-22 18:03:36.354: E/AndroidRuntime(16064):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)   I suspect it's related to , but not sure.  Specs:   Device model: Nexus 5 Android version: Android 6.0.1 SE app version: 1.0.82 (beta) Installed browser: Chrome 47.0.2526.83 (latest at current writing)
34848
I used to use the implicit call of toString when wanting some debug info about an object, because in case of the object is null it does not throw an Exception.  For instance:    System.out.println("obj: "+obj);   instead of:  System.out.println("obj: "+obj.toString());   Is there any difference apart from the null case? Can the latter case work, when the former does not?  Edit: What exactly is done, in case of the implicit call?
94655
I was experimenting with C++ and found the below code as very strange.   class Foo{ public:     virtual void say_virtual_hi(){         std::cout &lt;&lt; "Virtual Hi";     }      void say_hi()     {         std::cout &lt;&lt; "Hi";     } };  int main(int argc, char** argv) {     Foo* foo = 0;     foo-&gt;say_hi(); // works well     foo-&gt;say_virtual_hi(); // will crash the app     return 0; }   I know that the virtual method call crashes because it requires a vtable lookup and can only work with valid objects.   I have the following questions    How does the non virtual method say_hi work on a NULL pointer? Where does the object foo get allocated?   Any thoughts?
31499
Does assigning an unused object reference to null in Java improve the garbage collection process in any measurable way?  My experience with Java (and C#) has taught me that is often counter intuitive to try and outsmart the virtual machine or JIT compiler, but I've seen co-workers use this method and I am curious if this is a good practice to pick up or one of those voodoo programming superstitions?
120685
It seems to me that a lot of my debugging time is spent chasing down null-reference exceptions in complex statements. For instance:  For Each game As IHomeGame in _GamesToOpen.GetIterator()   Why, when I get a NullReferenceException, can I get the line number in the stack trace, but not the name of the object that equals null. In other words, why:  Object reference not set to an instance of an object.   instead of  _GamesToOpen is not set to an instance of an object.   or  Anonymous object returned by _GamesToOpen.GetIterator() is null.   or  game was set to null.   Is this strictly a design choice, meant to protect the anonymity of the code or is there a compelling reason in compiler design not to include this information in the debug-time exception?
77150
I have a Journey which sends the Subscriber SMS messages, 2/4 journey entries (all unique subscribers) don't receive the SMS.  The error displayed in the SMS activity in my Journey History is the following:      Failed - Object reference not set to an instance of an object.   Can anyone advise what this means? If it was configuration surely all subscribers wouldn't receive the message? I can confirm all subscribers have a mobile number and they use the same format and country code. Not sure if it helps but the entry source is Salesforce Data Entry.  Edit:  There can be entries where the Subscriber record does not exist in the AllSubscribers list as they do not have email addresses attached (only mobile numbers) but my journey only contains SMS message activities, no email. I have checked and even on some Subscribers that do have AllSubscribers records suffer the same activity error.
7315
Recently, apps that are fine an hour ago now crash when I open them. The crash report message seems to be caused by a null pointer exception (NPE) in com.google.android.trichromelibrary. Apps affected for me:  Gmail Dashlane  Is it just me, or is there actually something wrong with the library? How can I fix these affected apps? Crash report: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'Xiaomi/polaris/polaris:10/QKQ1.190828.002/20.9.4:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: ... pid: ..., tid: ..., name: com.dashlane &gt;&gt;&gt; com.dashlane &lt;&lt;&lt; uid: ... signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference          ...  backtrace:     #00 pc 00000000038621f0 /data/app/ com.google.android.trichromelibrary 438909034-YaxP9ttrIDcQBfleP5vm7Q==/base.apk! libmonochrome_64.so (offset 0x646000) (BuildId: ... )  (click  for the screenshot of the bug report)
107598
String queryFields = null;              for(Schema.FieldSetMember field : SObjectType.Task.FieldSets.Activity_Detail_Page.getFields()){                  queryFields = (queryFields == null ? field.getFieldPath() : queryFields+', '+field.getFieldPath());               }                String query = 'Select '+queryFields+' from Task where Id=\''+activityId+'\'';               task = Database.query(query);   i'll creating a field-set,now how do i add link on any field?  above code is  for dynamically query creation . below code of page   &lt;apex:pageBlock title="Activity" id="Block1"&gt;       &lt;apex:pageBlockSection title="Activity Detail"&gt;         &lt;apex:repeat value="{!$ObjectType.Task.FieldSets.Activity_Detail_Page}" var="field"&gt;             &lt;apex:outputField value="{!Task[field.fieldPath]}" /&gt;         &lt;/apex:repeat&gt;     &lt;/apex:pageBlockSection&gt; &lt;/apex:pageBlock&gt;    As per the image attached, I want to add a link in Rounded field that liks to account. Can any one help me?
90464
We noticed that lots of bugs in our software developed in C# (or Java) cause a NullReferenceException.  Is there a reason why "null" has even been included in the language?  After all, if there were no "null", I would have no bug, right?  In other words, what feature in the language couldn't work without null?
8114
I have same exception can please   The previous post issue is resolved.  Exception: :System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out  Visualforce Page   &lt;apex:page controller="Controller" action="{!init}" showHeader="false" sidebar="false"&gt;     &lt;center&gt;         &lt;apex:pageBlock title="Request Listener"&gt;&lt;/apex:pageBlock&gt;               &lt;/center&gt; &lt;/apex:page&gt;   Controller :            PUBLIC with sharing class Controller {        PUBLIC String fromNumber      = ApexPages.currentPage().getParameters().get('From');     PUBLIC String toNumber        = ApexPages.currentPage().getParameters().get('To');     PUBLIC String body            = ApexPages.currentPage().getParameters().get('Body');        PUBLIC PageReference init()     {                    System.debug('From Phone Number :' +fromNumber);         System.debug('To phone NUmber :' + toNumber);         System.debug('Message Body :' + body);          TwilioRestClient Client = TwilioAPI.getDefaultClient();                                                                SYSTEM.DEBUG('FROM AND To  Number is NOT NULL');                      String formattedNumber='+919876543210';                 IF(body != NULL)                 body = body;             ELSE                 body = '';             Case c = NEW Case (Subject = formattedNumber,Description = body,Origin = 'Phone');             INSERT c;                               Map&lt;String,String&gt; params1 = new Map&lt;String,String&gt;             {                'To'   =&gt; fromNumber,                'From' =&gt; '+1908280****',                'Body' =&gt; 'Conformation to customer'             };             TwilioMessage message = client.getAccount().getMessages().create(params1); /* Valid conformation SMS sent to the Customer.*/                                            return null ;     } }   While loin as admin then click preview on visualforce page executed but case is not created.I have checked the the debug log it throw the exception.
8224
Since many users are facing the NullReferenceException: Object reference not set to an instance of an object error in Unity, I thought that it would be a good idea to gather from multiple source some explanation and ways to fix this error.  Symptoms I am getting the error below appearing in my console, what does it mean and how do I fix it?  NullReferenceException: Object reference not set to an instance of an object
53255
In my spring application context file, I have something like:  &lt;util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String"&gt;     &lt;entry key="some_key" value="some value" /&gt;     &lt;entry key="some_key_2" value="some value" /&gt;    &lt;/util:map&gt;   In java class, the implementation looks like:  private Map&lt;String, String&gt; someMap = new HashMap&lt;String, String&gt;(); someMap = (HashMap&lt;String, String&gt;)getApplicationContext().getBean("someMap");   In Eclipse, I see a warning that says:  Type safety: Unchecked cast from Object to HashMap  What did I do wrong? How do I resolve the issue?
4656
I have this piece of code (summarized)...  AnsiString working(AnsiString format,...) {     va_list argptr;     AnsiString buff;      va_start(argptr, format);     buff.vprintf(format.c_str(), argptr);      va_end(argptr);     return buff; }   And, on the basis that pass by reference is preferred where possible, I changed it thusly.  AnsiString broken(const AnsiString &amp;format,...) { ... the rest, totally identical ... }   My calling code is like this:-  AnsiString s1, s2;     s1 = working("Hello %s", "World");     s2 = broken("Hello %s", "World");   But, s1 contains "Hello World", while s2 has "Hello (null)". I think this is due to the way va_start works, but I'm not exactly sure what's going on.
77222
I have a really simple Java class that effectively decorates a Map with input validation, with the obvious void set() and String get() methods.  I'd like to be able to effectively call those methods and handle return values and exceptions from outside the JVM, but still on the same machine Update: the caller I have in mind is not another JVM; thanks @Dave Ray  My implementation considerations are typical    performance ease of implementation and maintenance (simplicity?) reliability flexibility (i.e. can I call from a remote machine, etc.)   Is there a 'right way?' If not, what are my options, and what are the pro/cons for each?  (Stuff people have actually done and can provide real-life feedback on would be great!)
101830
There is a Java Void -- uppercase V-- . The only situation I have ever seen it used is to parameterize Callables    final Callable&lt;Void&gt; callable = new Callable&lt;Void&gt;() {             public Void call() {                 foobar();                 return null;             }         };   Are there any other uses for the Java Void reference type? Can it ever be assigned anything other than null? If yes, do you have examples?