FAQ Database Discussion Community


Object returns null

java,object,null
Summary: New to Java, tried looking through other posts but didn't find an answer. I'm learning inheritance and have an AddressBook class extended by a Runner class. When I write a program to test the inheritance I create a Runner object. If I get the first String parameter it returns...

RUBY: How to match a nil value in a hash

ruby,hash,null
I would like to ask you how can I match a nil value in a hash, e. g.: aAnimals = {1=>'dog', 2=>'cat'} puts laAnimals[1] # dog puts laAnimals[2] # cat puts laAnimals[3] # nil how can I put 'no animal' in case of nil values or higher than lenght of...

good practises null object return [closed]

c#,object,null,return
I have a question about c# programming language, when a method returns an object, and for example I'm forced to return null, which is not clean code, what is the best practise to handle this? I dont want to return null.

SQL Server - How make allow NULL value in column

sql,sql-server,null
I'm newbie level in SQL Server I want to allow null value in column, but it can't save. So I will re-create a new table with same structure. Please your help to allow null value in column with SQL script. Thank you.....

Null entities in DDD

c#,null,domain-driven-design,nullable
Take an example of a Product entity or aggregate which has a reference to another entity called Category. Before a domain event like CategorizeProduct happens, the Category's state is empty. To represent that in C#, I have to use NULL. I can't use Nullable<T> in C# because that can be...

Avoid EF update the null image to database in .Net MVC

asp.net-mvc,entity-framework,null,edit,httppostedfilebase
In my SachController, there is an Edit method like below. In the view, there are several textbox and one file-input for upload image object. Sometime, user doesn't want to change the image and they just don't select a new image. And the image (HttpPostedFileBase) is null. How can I avoid...

Sorting NULL values in PostgreSQL [duplicate]

sql,postgresql,sorting,null,sql-order-by
This question already has an answer here: PostgreSQL sort by datetime asc, null first? 2 answers In PostgreSQL, I'm using ORDER BY on columns of various types (NUMERIC, TEXT, BOOLEAN, TEXT[]). I'm designing an AJAX GUI where the users may interactively sort records by individual columns (in both ascending...

why use null != anything instead of anything!=null? [duplicate]

java,null,equals
This question already has an answer here: object==null or null==object? 9 answers I have seen various codes of my seniors and they have used this at many places.What effect does it have? why cant they include anything != null. This is true for below thing too "true".equals(x). Why is...

Replace the empty or NULL value with specific value in HIVE query result

hadoop,replace,null,hive
I'm trying to show a default value, "Others", when the query does not return any result for one of the selected columns. I'll show you the example. This query returns an empty value for os(agent) SO (in the first row): select country, os(agent) SO, count(*) from clicks_data where country is...

In Java, how can I fix this nullPointerException in a while loop?

java,loops,while-loop,nullpointerexception,null
In a java file I'm consistently having a runtime error Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at a line with a while loop and need to find a way to avoid this nullPointerException. My current code at this line looks like this : while (b.isOnBoard(row-i, col-i) && b.getState(row-i, col-i).equals(yourcolor)) { count++;...

Null Value from GetElementById using C#

c#,youtube,null,getelementbyid
I've gone through loads of already asked questions but I haven't been able to find a solution for my problem. My application is a video finder, the user enters what he/she is looking for in a textbox and then selects from one of three websites(Youtube,Metacafe,Screen.yahoo) to find the video. Ive...

SQL query not working for changing null values [closed]

sql,null,ms-access-2007
I have a database table with over 18,000 rows in Access 2007. I am trying to create a primary key but I have too many null values. Therefore, I would like to replace those null values with actual values. To do so, I wrote the following SQL statement: UPDATE [File]...

NULL result without error in PyObject_Call

python,c,null
I'm currently coding a Python C-Extension to perform some calculations in C instead of Python. It works just fine, I already got some nice results, but the point is, I get the following error: NULL result without error in PyObject_Call It occurs sometimes, not always, when I want to create...

Sliders providing null values to complex shiny application at startup and periodically as inputs change

javascript,r,html5,null,shiny
I am currently developing a complex (multiple pages of nested navs/tabs) web application using R's Shiny package. I am currently experiencing an issue where sometimes accessing the values of these sliders from R via input$ returns NULL for no apparent reason. When this happens, the various outputs dependent on these...

Android async class returns null

java,android,asynchronous,null
I'm trying to fix this code: public class Async_Test extends AsyncTask<String, String, String> { private String Response; @Override protected String doInBackground(String... params) { String tmp = "something"; return tmp; } @Override protected void onPostExecute(String result) { Response = result; } public String getResponse() { return this.Response; } } The problem...

CoreData TextField - unexpectedly found nil

ios,xcode,swift,core-data,null
I'm doing application with CoreData and textfields in tableview. In storyboard I have one textfield. textfield will multiply five times with different content in application. In navigation bar I have button that will save your written data. But when I press save button, application crash with error IBOutlet is in...

Why the AVAudioPlayer var equals nil? - Swift

swift,null,avaudioplayer,nsbundle
This is my function: func playMusic(filename :String!) { var playIt : AVAudioPlayer! let url = NSBundle.mainBundle().URLForResource(filename, withExtension: nil) if url == nil { println("could not find \(filename)") return } var error : NSError? playIt = AVAudioPlayer(contentsOfURL: url, error: &error) if playIt==nil { println("could not create audio player") return } playIt.numberOfLoops...

Check if String array element is null

java,arrays,string,null
So I have looked in to some other threads about this issue and it seems like if I should be able to use the regular comparison operators to check this. How to check if my string is equal to null? Java, check whether a string is not null and not...

Removing empty rows in excel using C#

c#,excel,null,delete-row
I want to remove empty rows at the end of program exection. In details I am inserting some results after calculation using C# in predefined excel sheets. At the end I need to delete/remove the empty rows programatically. Could any one suggest solution. My code is little big so I...

Line ChartJS empty / null values doesn't break the line

null,break,chartjs
I want to break the line of the chart when values is null or empty, but I can't. Perhaps I miss something? var data = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [ { label: "My First dataset", fillColor: "rgba(220,220,220,0.5)", strokeColor: "rgba(220,220,220,0.8)", highlightFill: "rgba(220,220,220,0.75)", highlightStroke: "rgba(220,220,220,1)", data:...

Should I do obj = null after arraylist.add(obj)

java,arrays,object,memory-leaks,null
I was just wondering if we should do obj = null after adding it into an array. Note that this is about a special case, read below. First, let's consider class A like this: public class A { public void doSomething(B object) { // some code here } } and...

Comparison of Fixnum with nil failed - palindrome program Ruby

arrays,ruby,null,palindrome,fixnum
I was working on a program for question 4 in Project Euler - find the largest palindrome among multiples of 3-digit numbers. This is what I wrote: def palintest(number) num = number.to_s len = num.length if len % 2 != 0 num[(len/2).floor] = '' end if num[0.. (len/2)-1] == num...

Crystal Reports and Null fields

crystal-reports,null
I'm using formula by grouping records in my report like this: field1 + field2 + field3 But when a field inside the formula is null (for example field2) Crystal Reports not groups records properly; So I have to insert in the formula a condition like: field1 + (if isnull(field2) then...

Both null and empty char are equal in java

java,database,null,char
I have doubt while taking a null or empty char check in Java. Is both have to be checked in any way. For example in database the variable length for Char is 1 . It will allow null as well. So if you have empty char does it mean null?...

Condition on resultset of a select that return null or not null values-Java

java,sql,select,null
For an application,I am checking if a table is filled so that I can retrieve that from it; otherwise I will retrive from another table. For that, I use a select and checks if it has null values by wasnull(). If it does, I execute a query; otherwise, I execute...

What if I need to differentiate 0 from NULL in C++?

c++,null,return-value
** Please don't criticize the purpose of the code itself. It's from Pat Morin's Open Data Structures book. Not my first choice, its assigned reading/practice. I just wanted to know if there is a way to differentiate, or a better way to go about this. Textbook--> http://opendatastructures.org/ods-cpp/** ** Another note:...

Oracle SQL - replace null with previous known value

sql,oracle,null
I am looking to replace null values from my table's column with the previous known value from that column. I have tried and searched many things but I can't seem to figure out how to do it. If someone could help that would be great. Thanks in advance! PROCESSO DATAM...

Returning Null Value for Unknown Type

c#,generics,null,nullable
I'm trying to write the following method using generics. (My actual method is more complex than this.) public T ParseDictionaryItem<T>(string s, Dictionary<string, T> dictionary) { T result; if (dictionary.TryGetValue(s, out result)) return result; // TODO: Return special value such as null to indicate invalid item } My goal is to...

How to see if result of SQL query is empty before performing other queries in PHP

php,mysql,database,null
I have the following PHP code which is for a voting system of an app. Its a Q&A app, and the user can vote for questions and answers that are posted. In my php code, I first check if the user has voted for a specific question. This would exist...

Specified cast is not valid. c# mdb database

c#,ms-access,null
I'm using mdb database with my c# application, I have table products which has 3 columns (Id,Name,Note), note column contain NULL values. objConn.Open(); listView1.Items.Clear(); OleDbCommand cmd = new OleDbCommand("select prod_Id,prod_Name,prod_Note from products", objConn); OleDbDataReader dataReader = cmd.ExecuteReader(); int i = 0; while (dataReader.Read()) { listView1.Items.Add(dataReader.GetValue(0).ToString()); listView1.Items[i].SubItems.Add(dataReader.GetString(1).ToString());...

How do I ignore the nil values in the loop with parsed values from Mechanize?

ruby,null,mechanize-ruby
In my text file are a list of URLs. Using Mechanize I'm using that list to parse out the title and meta description. However, some of those URL pages don't have a meta description which stops my script with a nil error: undefined method `[]' for nil:NilClass (NoMethodError) I've read...

indexOf can find null

java,arraylist,null
This is my implementation of the indexOf method (custom arraylist class) public int indexOf(String string) { for(int i = 0; i < size; i++) { if(strings[i].equalsIgnoreCase(string)){ return i; } } return -1; } This is the code that should return null, but which doesn't. I don't understand why public void...

Pandas not recognizing NaN as null

python,pandas,null
I have a DataFrame, a portion of it which looks like this: I read in the file using this line of code: df = pd.read_table(oname,skiprows=1,sep='\t',usecols=(3,4,5),names=['year','month','snow_depth']) When I call df.isnull(), I get False for each cell when the NaN should come up as True by default, I believe. Does anyone have...

C++ Setting Element in Struct Array = NULL

c++,arrays,function,struct,null
So what my code does right now is it creates a deck of cards using an emulated stack (since I could not figure out how to implement a real stack in c++).The cards are then shuffled, and then the deck is split in half and passed to two players, p1...

Why does this string extension method not throw an exception?

c#,null,comparison,ienumerable,argumentnullexception
I've got a C# string extension method that should return an IEnumerable<int> of all the indexes of a substring within a string. It works perfectly for its intended purpose and the expected results are returned (as proven by one of my tests, although not the one below), but another unit...

Assert Failed Expected: Actual:<(null)>

c#,unit-testing,null,assert
So I'm unit testing and I got the above message. I've looked around and cannot find an answer to my problem. I have no idea what this means. Can there be two different kinds of Null? Thanks for the help! //This is invalid input given to the CategoryList constructor. It...

node.js array check fails conditional is processed even while returning false

javascript,arrays,regex,node.js,null
I have a buffer in node.js and I'm checking for mime type with regex. There is a capturing group in regex and if it is successfull it must return this capturing group at index 1 in the array returned by exec. I'm using if(mime.exec(dt)[1]){ tip.push(mime.exec(dt)[1]); } this control and I...

How to handle null in xml and c# -2

c#,xml,wpf,null,deserialization
Let's consider that this was automatically generated xml file and in the second Address tag there is nothing. It is null. If it was not null , we are going to make a list for address and then continue with a class declaration as below. But if we do so,...

How to Nil a object in Swift

ios,swift,cocoa-touch,null
How to assign nil to an object in Swift. I'm getting error if assigned directly. ...

PHP Loose comparison and null on Switch

php,null,switch-statement,comparison,case
Today I saw a strange bug on my code. I have a switch with comparison on case and if my variable equals null or '' it will always comes in the first case. My code : $sHost = filter_input(INPUT_SERVER, 'HTTP_HOST'); switch($sHost){ // Local case strpos($sHost, "dev.localhost") !== false: $this->_sEnv =...

PostgreSQL COPY CSV with two NULL strings

postgresql,csv,null
I have a source of csv files from a web query which contains two variations of a string that I would like to class as NULL when copying to a PostgreSQL table. e.g. COPY my_table FROM STDIN WITH CSV DELIMITER AS ',' NULL AS ('N/A', 'Not applicable'); I know this...

Handle nil value in Swift

ios,swift,null
NSString(data: data, encoding: NSUTF8StringEncoding) returns nil. (correct) If the value is nil I need to set variable stringResponse to "" else to what NSString(data: data, encoding: NSUTF8StringEncoding) returns. I am doing it this way: override func start() { if self.cancelled { return } var stringResponse: String? var urlString: String! if...

Returning nil while getting data from parse.com

ios,swift,parse.com,null
I want to retrieve data from my parse class. I want to save them in strings. Here is my code: var query = PFQuery(className:"Tags") query.getObjectInBackgroundWithId("IsRTwW1dHY") { (gameScore2: PFObject?, error: NSError?) -> Void in if error == nil && gameScore2 != nil { let username = self.gameScore2["username"] as? String let tagtext...

C# OpenFileDialog - exception when no files are chosen

c#,wpf,exception,null,openfiledialog
I am trying to work out on this error, when no files are chosen the program obviously goes to do next step although it shouldn't. I have tried: if (fileToCheck != null) but it didn't work. Any other suggestions? private void Mail(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new...

How to assign Google protocol buffer SerializeAsString() output which contains embedded nulls to std::string?

c++,serialization,null,protocol-buffers,stdstring
I am trying to serialize the message as string in C++ using google protocol buffer and assign the serialized result (which contains embedded nulls in it) to std::string. Following is my code: std::string result = message.SerializeAsString(); It is ignoring the characters after the first \0 character. result is not having...

Concatenation of a null String object and a string literal

java,string,null
This is a follow-up question to some previous questions about String initialization in Java. After some small tests in Java, I'm facing the following question: Why can I execute this statement String concatenated = str2 + " a_literal_string"; when str2 a String object initialized to null (String str2 = null;)...

Spring data JPA and parameters that can be null

java,parameters,null,spring-data-jpa
My understanding is, that with Spring data JPA I cannot have a query method to fetch all rows where a column equals a given non-null method parameter and use the same method to fetch all rows where this column is NULL when the method parameter is null. Is that correct?...

Google Protocol Buffer serialized string can contain embedded NULL characters in it?

c++,serialization,null,protocol-buffers,stdstring
I am using Google Protocol Buffer for message serialization. This is my sample proto file content. package MessageParam; message Sample { message WordRec { optional uint64 id = 1; optional string word = 2; optional double value = 3; } message WordSequence { repeated WordRec WordSeq = 1; } }...

Variable from enclosing block becomes null in anonymous function

c#,wpf,multithreading,null,anonymous-function
var client = new WebClient(); var bytes = client.DownloadData(webUrl); <-- NOT null Application.Current.Dispatcher.BeginInvoke(new Action(() => { BitmapImage img = new BitmapImage(); img.BeginInit(); img.StreamSource = new MemoryStream(bytes); <-- null img.EndInit(); img_DownloadCompleted(img, webUrl); })); The above code is executed in a thread as to avoid blocking the UI. I am trying to...

Null Pointer Exception adding null check [duplicate]

java,nullpointerexception,null
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers Simple and best way to solve Null pointer exception at this line: oS = ((SyIntBVO)syIntBVOList.get(0)).getSource().trim(); Exception on getSource variable. how to add null check?...

Cannot set property 'innerHTML' of null Javascript validation

javascript,validation,null
I get in the console a error of Cannot set property 'innerHTML'of null, how can i fix that the text after document.getElementById won't flash away after 1 sec. I added HTML code now, but when i want to post the button i only want to submit the form when everything...

Behaviour of null in Java

java,nullpointerexception,null,concatenation
This probably looks duplicate of other questions on SO. But, I was wondering the way Java treat null. Eg: public class Work { String x = null; String y; Integer z; public static void main(String arg[]) { Work w = new Work(); w.x = w.x + w.y; // work Line...

what happens if puts() function doesn't encounter null character?

c,null,puts
Consider following program. #include <stdio.h> int main(void) { char side_a[] = "Side A"; char dont[] = {'W', 'O', 'W', '!' }; char side_b[] = "Side B"; puts(dont); /* dont is not a string */ return 0; } I know that puts() function stops when it encounters the null character. But...

Why is my data being truncated? Warning | 1265 | Data truncated for column

mysql,date,null,warnings,truncated
I tried adding NULL to both date_of_birth and date_of_death, but that didn't help. Why is data being truncated? (especially because there isn't any data at the moment...) Also, I don't understand warning 1261 at all. Row 5 is no different from rows 1-4. Thanks! The following script: -- create the...

java mysql input NULL

java,mysql,insert,null
I am using MySQL Server 5.6, Tomcat 8.0. I can create an SQL input statement that is successful in putting hard coded values into my table but if I try to use a variable instead, it appears as NULL in the table. I have println statements immediately before the SQL...

ZF2 Doctrine with Symfony < OR null query

symfony2,doctrine2,null,zend-framework2
How do I write this "WHERE" condition in a way which is compatible with Doctrine? ( ( `translations_es_google`.`translation_date` < `translations_masters`.`translation_date` ) OR ( `translations_es_google`.`translation_date` is null ) ) What I have tried (unsuccessfully) are: $query1 ->andWhere('((t.translationDate < m.translationDate) OR (t.translationDate is NULL))'); $query1 ->andWhere('(t.translationDate < m.translationDate) OR (t.translationDate is NULL)');...

Why is my Rigidbody != null immediately after seeing that it is null?

c#,generics,unity3d,null
I am checking to see if "My Game Object" has a Rigidbody. It does not. But the conditional for the null check on Rigidbody fails, despite having just been proven null. Why is this happening? How can I make my condition block run? using UnityEngine; using System.Collections; public class NullChecker...

Sum, Avg, Max, Min, Count of NULL values

mysql,sql,null,sum
In MySQL SELECT 2+NULL FROM tbl_name will return NULL, since MySQL cannot interpret NULL as a number. But why will SELECT SUM(quantity) FROM tbl_name not return NULL if just one of the values is NULL? The same goes for MIN, MAX, AVG, etc. Since MySQL doesn't know what NULL could...

Instance method returns correct array from one view controller but null from others

objective-c,xcode,methods,null,instance
This is my first post so apologies for any errors I make, but this has been frustrating me for hours now and I cannot find a solution. I have an app that uses a UITabBarViewController that has 3 tabs: FirstViewController, SecondViewController and ThirdViewController. I have an NSObject class (Manager) where...

Calling a get name method for an object returns null

java,object,methods,null
I have a method that goes through each element in the ArrayList 'Clearance' and if it is an instance of HighClearance I want to add it to a String list of names. Problem: Whenever I call the getName() method which is in the 'Clearance' superclass, it just returns null and...

Java- HashMap.get returns null when it shouldn't

java,android,null,hashmap
I am using a HashMap to link some strings to integers, which are then used to index a list. The strings I am using in .get() are passed to a method, from an android spinner, and are definitely correct as I outputted them to the log, and they match those...

When to write NOT NULL when creating a MySQL table column

mysql,sql,database,null,notnull
What's the difference or benefit of writing "NOT NULL" in a mysql field creation... For example if I'm creating a table like this... CREATE TABLE IF NOT EXISTS game( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(128) NOT NULL, description VARCHAR(200) NOT NULL, PRIMARY KEY(id) ) Here, id and name always...

How do I set this map value to null in JSTL?

null,hashmap,jstl
In JSTL, I have HashMap as a page variable. The HashMap maps Strings to more complex Objects. I would like to set a value to null. So I'm trying value: ${myMap[myId]} <c:set target="myMap" property="${myId}" value="${null}" /> I have verified taht the "value:" statement does print something out, however, I get...

Joining an ID with a NULL

sql,sql-server,select,null,sql-server-2012
I'm trying to join a table of data to another table, but one of the ID that I'll be joining on is NULL. However, I have a specific ID I want it to link to with the NULLs. I might be oversimplifying this question too much with this example, but...

How do I represent an Optional String in Go?

string,go,null,optional,variant
I wish to model a value which can have two possible forms: absent, or a string. The natural way to do this is with Maybe String, or Optional<String>, or string option, etc. However, Go does not have variant types like this. I then thought, following Java, C, etc., that the...

Variables are null even after assigning a value to them (Java)

java,class,variables,methods,null
I'm trying to write a method that will add song information (input by the user) to a database. Once the user adds the song details (name, artist, file size, duration), they should be saved in the first empty song slot (4 song slots total) and then taken back to the...

Comparable and (MyClass)null

java,nullpointerexception,null,compare,comparable
Say I have public class MyClass implements Comparable<MyClass> { public int compareTo(MyClass mc) { //<implementation ommited>... } } The docs for Comparable say that "The natural ordering for a class C is said to be consistent with equals if and only if e1.compareTo(e2) == 0 has the same boolean value...

PostgreSQL multiple nullable columns in unique constraint

sql,postgresql,database-design,null,unique-constraint
We have a legacy database schema that has some interesting design decisions. Until recently, we have only supported Oracle and SQL Server, but we are trying to add support for PostgreSQL, which has brought up an interesting problem. I have searched Stack Overflow and the rest of the internet and...

How to handle no rows returned in an Oracle update using a common sub-select

oracle,null,sql-update,subquery
Consider the update: UPDATE table1 SET c1 = NVL(( SELECT d1 FROM table2 WHERE table1.id = table2.id ), 0), c2 = NVL(( SELECT d2 FROM table2 WHERE table1.id = table2.id ), 0) The NVL function handles the case where the sub-select returns no rows. Is there a good way to...

writing string to file in java

java,string,file,null
Below two classes. I have a problem with writing string to file in java. Why in my file xml.txt I get null? Why I can't write String a = px.readXml(url) ? In xml.txt I've only null package xml; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.net.*; import java.util.StringTokenizer; import javax.xml.parsers.*;...

How to persist null value from server? (Groovy and JavaScript)

javascript,groovy,model,null
I'm returning an object (cmd) in the model from my Groovy controller. However, in the JavaScript in the GSP, it's converting null values to empty strings. For instance, <script> name:'${cmd.name.encodeAsHTML()}' </script> Omitting the quotes around the interpolation piece throws an error. How can I force the null value from the...

foreign key constraints. can child table have null values? ERROR 1452 (23000)

mysql,database-design,null,foreign-keys
I have a controlled vocabulary table set up as such: -- create the film_stock table DROP TABLE IF EXISTS film_stock; CREATE TABLE film_stock ( stock varchar (10) NOT NULL, PRIMARY KEY(stock)) ENGINE = INNODB; There are only two values assigned to 'stock' - Nitrate and Acetate. 'stock' serves as a...

Java Getting String from another class returning null

java,string,null
I currently have two constructors in one of my classes, one going to my main class, and the other to another class that has most of the methods that I use. The reason I don't use static methods for my second class that I have a constructor, is that I...

How to store nil with Rails.cache.fetch & memcache?

ruby-on-rails,ruby-on-rails-3,caching,null,memcached
I have an existing Model singleton method triggering expensive database queries that I want to model cache. To do this, I wrapped a Rails.cache.fetch() call around the method in question: # app/models/specialist.rb class Specialist < ActiveRecord::Base def city Rails.cache.fetch([self.class.name, self.id, "city"], expires_in: 23.hours) do # expensive legacy query: if responded?...

Swift won't allow me to use `!=`

ios,swift,if-statement,null
Currently trying to check if three values, that I just converted from Strings to doubles, are nil from the UITextFields aValue, bValue, and cValue. I don't get a compile error from these variables until the if statement at the bottom of the code block (shown below) where it causes a...

Throwing SAXException

java,xml,exception,null,sax
Learning xml parsing with Java, and am working in a test program to try things out as I go. All of the test System.out.println()'s were what I expected in the console except childElement was returning [name: null] and childElement.getNodeValue() was returning null rather than [name: "Branch Name"] and "Branch Name"...

In Java, how can I avoid blank jtextfield input?

java,null,jtextfield
Due to a gui with a lot of buttons and labels, I'm using netbeans. When I test-run it in netbeans, if I leave the jtextfield blank and submit it, I get: Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 I was looking at the jbutton I am using to submit the data...

Getting a null value in Firebase rest response

rest,null,firebase,restful-url
I am trying to create a restful service using firebase as backend. I have created a sample app and when I hit this url [ https://poctest1.firebaseio.com/rest.json ], I am getting the following response. [ null, { "value": "test1" }, { "value": "test 2" } ] Why am I getting a...

global variable returns null when sent to list

php,variables,null,return,global
I'm currently working with these two parts of code. One is for receiving the data and one for displaying it in a list, but for some reason the variable $emp_name always returns null when I'm trying to display it in the second part. The idea is to search an employee...

Strange behaviour when checking for NULL character in 'C'

c,pointers,null
To clarify a point I have written two small test programs given below. #include <stdio.h> int main(int argc, char *argv[]) { char *p = "ab"; p++; p++; if (*p) printf("p is not NULL \n"); else printf("ps is NULL \n"); return 0; } The program above initalizes the char pointer p...

Sort when values are None or empty strings python

python,list,sorting,null
I have a list with dictionaries in which I sort them on different values. I'm doing it with these lines of code: def orderBy(self, col, dir, objlist): if dir == 'asc': sorted_objects = sorted(objlist, key=lambda k: k[col]) else: sorted_objects = sorted(objlist, key=lambda k: k[col], reverse=True) return sorted_objects Now the problem...

NULL values in where condition is not working

mysql,sql,select,null
I have encountered a weird problem in a MySQL query. This following query is returning me 0 result whereas there are many rows which should be returned. the query is SELECT DISTINCT SKU, EAN, URL, CID FROM tab_comp_data WHERE status ='' And in many rows there are NULL values in...

NSKeyedArchiver: key returning nil - Swift

ios,swift,null,nskeyedarchiver
I'm having some issues here. I'm trying to store some information with NSKeyedArchiver, but when I run the app, I get: fatal error: unexpectedly found nil while unwrapping an Optional value. Apple docs says: "If you invoke one of the decode... methods of this class using a key that does...

NullPointerException (Java)

java,variables,methods,null,instance
I've tried looking at posts on this issue but am still having some trouble with this error in my code. So in the fourth line, I create an instance variable called SongDatabase to access the SongDatabase class. But when I get down to the line, SongDatabase.addNewSong(); under case 1, I...

Calling function within inline condition expression in Swift

function,swift,null,inline
I am trying to use inline if condition as follows: topDisplay.text!.rangeOfString(".") != nil ? call function A : call function B The idea here is if there is "." in the topDisplay.text! then call function A, otherwise, call function B. The method, rangeOfString, returns nil if no "." is found....

Swift: required condition is false: file != nil

ios,swift,null,avaudioengine,avaudioplayernode
The app runs fine but as soon as I tap chipmunkButton the app crashes and provides the following error: ERROR: AVAudioPlayerNode.mm:678: -[AVAudioPlayerNode scheduleFile:atTime:completionHandler:]: required condition is false: file != nil 2015-05-10 17:24:25.269 Pitch Perfect[50278:1897012] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: file != nil'...

Swift 1.2 - Setting element in array of optional types to nil— not allowed when passed in?

ios,swift,null,sprite-kit
I have an array of boxes where the types are Box? to allow elements to be set to nil, if there is nothing there. I want the Box to set its spot to nil when it is removed from the scene. The following causes no complaints from Xcode: override func...

Casting “as? Int” in Swift yields different results for different numbers

ios,swift,casting,null
I have an iOS app that worked fine, until at some point it started crashing on a nil value for a certain number. After doing some tests in my code I managed to boil it down to the following piece of code that yields an output that does not make...

PHP - SQL query containing unicode is returning NULL for some reason

php,mysql,unicode,null
I am trying to run this query: SELECT trans FROM `dictionary` WHERE `word` LIKE 'Çiçek' like this (relevant code): function gettranslation($word){ return $this->query("SELECT trans FROM `dictionary` WHERE `word` LIKE '$word'"); } function query($query){ $result=mysqli_query($this->conn, "set character_set_results='utf8'"); $result=mysqli_query($this->conn, $query); return $row = mysqli_fetch_row($result)[0]; } My mySQL table is made like this:...

Stack with push and pop functions not working

c++,null,crash,stack
This is the program. #include<iostream> #include<string> using namespace std; struct stack { int inf; stack* link; } *start, *p; void push(stack*, stack*, int); void pop(stack*, stack*); int main() { int s = 0; string thing; cin >> thing; while (thing != "end") { if (thing == "push") { push(start, p,...

Distinguish between not set at all AND null?

php,null
$record['field'] = null; if (isset($record['field']) || is_null($record['field'])) { // When $record['field'] is set and not null, OR, when $record['field'] = null // Basically, when $record['field'] is defined as $record['field'] = whatever, even null. } else { // When $record['field'] is not defined at all, not even null } My intention...

Understanding null object vs 0 as number [duplicate]

javascript,object,null,numbers
This question already has an answer here: Why null in javascript is bigger than -1, less than 1, but not equal (==) to 0? what is exactly then? 2 answers I was on Codewars trying to complete some of the tasks and one question asked Create a toDense() function...

Multiple NULL addition into a List in Java

java,list,concurrency,null,add
I have 2 lists and want to copy some element from one to another, i.e. there are old and new employees list I need to union 2 lists and delete the elements that include to the old list but not include in the new one. I could solve the part...

Merge multiple records in single row

sql,oracle,oracle11g,null,group
I am trying to get two separate records to display on a single line, but keep getting multiple lines with nulls. I thought that if I grouped by Test_Date, I'd be able to get a single row for each test date, with the scores on a single line, but as...

How do I pass an empty array to the constructor in java?

java,arrays,constructor,null
This is the code: // Default constructor public Bestellung() { this(null, null, null); } // Initial constructor public Bestellung(LocalDateTime zeitstempelBestellung, LocalDateTime zeitstempelAuslieferung, PizzaVO[] warenkorb, int index) { super(); this.zeitstempelBestellung = zeitstempelBestellung; this.zeitstempelAuslieferung = zeitstempelAuslieferung; this.warenkorb = warenkorb; this.index = index; } I'd like to finish the default constructor. Therefore I...

IEnumerable Ajax.Beginform to Controller is null

model,controller,null,ajax.beginform
I have a view contains a list of users that is passed through the model. What I want to do is have a button for each user using which passes the userId back to the controller so that I could store it. Similar to a Like/Unlike Button. @model IEnumerable<FindaRoom.Models.FilterViewModel> <h3>List...

Parse PFQuery returns nil (swift)

ios,swift,parse.com,null,pfquery
I am trying to add to an array of a class I created called "Party" called "parties" to use in a UITableView, but the function I created returns a nil value for the arrays even though there is one in Parse. I created the array in my view controller like...

Global assignment within a reactive expression in R Shiny?

r,null,shiny,variable-assignment
suppose I have a data object that is uploaded by the user: data <- reactive({ inFile <- input$file if (is.null(inFile)) return(NULL) data <- read.csv(inFile$datapath) return(data) }) And suppose I want to delete columns in the dataset. I want to set it to global assignment so that I can run the...

Differences between null and StringUtils.isBlank()

java,null
I want to check if a String is empty or not and I would like to know the differences between the following and which one is better and on which occasions. Specially because I'm getting this error if I use "isNotBlank": "cannot be cast to java.lang.String". this.text.getData() != null <---...

Check if the following position of a pointer is null or end of line C++

c++,string,pointers,null
Well, I have an iterator over a string in C++ std::string::iterator itB = itC->begin(); And I want to check if the next position of the iterator reaches the end of the line. I've tried this: if(*itB ++ != NULL) Also this: itB++ == itC->end() But now I'm really confused and...