nullpointerexception

NullPointerException When Entering Data Into a Dynamic Array from Text File

这一生的挚爱 提交于 2019-12-20 06:20:52
问题 I am making a voting system where the user logs in with their student number and makes a selection. Once someone has voted, they cannot be able to log in again. I made an object; Students, containing a String for the student number and a boolean for whether or not that student number has already voted (both being private). I made a dynamic array of this type as to accept a given amount of students off of a text file that is read through the use of a Scanner. However, when I try to populate

I can't figure out what's wrong with my NullPointerException or why it even exists

て烟熏妆下的殇ゞ 提交于 2019-12-20 05:52:21
问题 What are they? My application keeps crashing whenever I try to pass an object over to my database helper. The variable name is "e". I've had the data in the object display in a toast notification and everything is fine but when i try to pass it to the database helper I get nothing. I've even added Logs to every second line but nothing gets passed as the method never starts. I also tried adding the values from the object into separate variables and passing them through (I rewrote the helper

NullPointerException when trying to get DefaultSharedPreferences for Activity

守給你的承諾、 提交于 2019-12-20 04:46:31
问题 I have to develop an app for an internship and I'm using AndroidStudio. For now I'm just trying things and I'm developping a Spank counters app (yeah yeah I know). I know that there is already a response there : What is a NullPointerException, and how do I fix it? and many other questions similar to mine. The fact is I understant the error but I can't find it in my code. (I havn't put the xml file because I don't think it's usefull bet let me konw if you want to see it.) Sorry if it's hard to

NullPointerException when trying to insert into SQLite - Android

佐手、 提交于 2019-12-20 04:18:12
问题 Anyone who follows Android tags are probably familiar with me. I am having the hardest time implementing a SQLite database for my highscores. This is also my first time working with SQLite. I am trying to insert just two variables -- int and long. My insert() method is not working correctly. Any advice other than the stuff talked about above is also appreciated. Thank you in advance for your help. Highscores.java public class Highscores extends Activity { DatabaseHelper dh; SQLiteDatabase db;

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-20 04:13:04
问题 This question already has answers here : findViewByID returns null (28 answers) Closed 3 years ago . java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference I want to make the icon/image of the first activity transfer or move to the second activity but this error above show up. This is my source code in the first actvty: public void next (View view){ Intent intent = new Intent(this, Products.class);

NullPointerException custom listview adapter

烈酒焚心 提交于 2019-12-20 04:10:48
问题 Hello stackoverflow community, I'm getting a NPE in my getView method of my custom adapter class which extends BaseAdapter. I hope you can help me. Here's my getView method: @Override public View getView(int pos, View convertView, ViewGroup viewGroup) { if(convertView==null){ LayoutInflater inflater = (LayoutInflater)context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.row, null); } TextView datetv = (TextView) convertView.findViewById(R.id.date)

Android Fragment lifecycle issue (NullPointerException on onActivityResult)

吃可爱长大的小学妹 提交于 2019-12-20 03:24:08
问题 I get an issue which for I cannot find any explanation. I have a FragmentActivity that displays fragments using a TabManager, as follows : public class WorkOrderFormTabFragmentActivity extends FragmentActivity { TabHost mTabHost; TabManager mTabManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.work_order_form_tab_new); mTabHost = (TabHost)findViewById(android.R.id

java.lang.NullPointerException at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter

丶灬走出姿态 提交于 2019-12-20 02:07:09
问题 I have in my JSF 2 app on JBoss AS 7.1 a PrimeFaces 5.1 datatable with lazy loading and it sorts on page load, so I know my sorting implementation works, but when I click the column to sort it throws the below exception. 17:48:34,855 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/feenix].[Faces Servlet]] (http-/0:0:0:0:0:0:0:0:8080-6) JBWEB000236: Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException at com.sun.faces.context

Null Pointer Exception Java

…衆ロ難τιáo~ 提交于 2019-12-19 21:53:51
问题 I'm just starting out with learning Java, and have run into a problem. When trying to run an Android application, I get a NullPointerException when the method makeResponse is called. Code extract (full code appended at the end of this post): private String makeResponse(String input){ //This doesn't work yet. I keep getting null pointer exceptions on the line beginning "int id" line, but can't tell why. String response = "You picked "+input; if (sw==null){ response+=" and sw is null"; //This

why does this code throw a NullPointerException?

为君一笑 提交于 2019-12-19 17:46:48
问题 Eventually I got the answer, but it puzzled me for a while. Why does the following code throws NullPointerException when run? import java.util.*; class WhyNullPointerException { public static void main( String [] args ){ // Create a map Map<String,Integer> m = new HashMap<String,Integer>(); // Get the previous value, obviously null. Integer a = m.get( "oscar" ); // If a is null put 1, else increase a int p = a == null ? m.put( "oscar", 1) : m.put( "oscar", a++ ); // Stacktrace reports Npe in