basics

Java indexOf returns false for unfound string?

I need to know whether in Java does the indexOf() method return false or void for an unfound string? or does it return an index int of 0? ...

How do I access the name of the class of an Object in Python?

The title says it mostly. If I have an object in Python and want to access the name of the class it is instantiated from is there a standard way to do this? ...

What is the best way to get the last element of a list in python?

I found many different ways of getting the last element from a list in python alist[-1] alist[len(alist) -1] Which is the way you would do this? ...

What is the simplest way to convert a const char[] to a string in c++

Is there a simple way of creating a std::string out of an const char[] ? I mean something simpler then: std::stringstream stream; stream << const_char; std::string string = stream.str(); ...

How do I make python to wait for a pressed key

I want my script to wait until my users presses the any key. How do I do that? ...

How does Java's Hello World work without an object instance?

Hi, I'm a newbie to Java and I'm confused about something: In the simple hello world program in Java, no object is created so how does the class work in the following example? public class HelloWorld { public static void main (String args[]) { System.out.println ("Hello World!"); } } ...

How to quit a C++ program?

How do I quit a C++ program. Which function is called to end a program and which values does the method take? To clarify I want to exit a C++ program from within my code. And I may want to exit the program outside of the main function of this program. ...

How to initialize log4j properly?

After adding log4j to my application I get the following output every time I execute my application: log4j:WARN No appenders could be found for logger (slideselector.facedata.FaceDataParser). log4j:WARN Please initialize the log4j system properly. It seems this means a configuration file is missing. Where should this config file be l...

Count occurrence of a character in a Python string

What's the simplest way to count the number of occurrences of a character in a string? e.g. count the number of times 'a' appears in 'Mary had a little lamb' ...

Or versus OrElse

Whats the difference between or and OrElse? if temp is dbnull.value or temp = 0 produces the error *Operator '=' is not defined for type 'DBNull' and type 'Integer'.** while this one works like a charm! if temp is dbnull.value OrElse temp = 0 ...

How do I get the nth element from a Dictionary?

cipher = new Dictionary<char,int>; cipher.Add( 'a', 324 ); cipher.Add( 'b', 553 ); cipher.Add( 'c', 915 ); How to get the 2nd element? For example, I'd like something like: KeyValuePair pair = cipher[1] where pair contains ( 'b', 553 ) thanks! Based on thecoop's suggestion using a List, things are workking: List<KeyValuePair<ch...

convert a char* to std::string

I need to use std::string to store data retrieved by fgets(). To do this I need to convert fgets() char* output into an std::string to store in an array. How can this be done? ...

In C#, what does "Customer cust = new Customer();" do?

Customer cust = new Customer(); Customer is a class. cust is an assigned name. I'm not sure what Customer() does... What does this line do? Why do we need it? Isn't having Customer and Customer() a bit repetitive? ...

Abstract class - Java basics

Can an abstract class have a final method in Java? ...

What does jquery $ actually return?

I have read the JQuery documentation, and while much attention is devoted to what you should pass the function, I don't see any information on what it actually returns. In particular, does it always return an array, even if only one element is found? Does it return null when nothing is found? Where is this documented? I understand th...

Way to get number of digits in an int?

Is there a neater way for getting the length of an int as this? int length = String.valueOf(1000).length(); ...

SQL: what exactly do Primary Keys and Indexes do?

Hi I've recently started developing my first serious application which uses a SQL database, and I'm using phpMyAdmin to set up the tables. There are a couple optional "features" I can give various columns, and I'm not entirely sure what they do: Primary Key Index I know what a PK is for and how to use it, but I guess my question wit...

Are const arrays declared within a function stored on the stack?

if this was declared within a function, would it be declared on the stack? (it being const is what makes me wonder) void someFunction() { const unsigned int actions[8] = { e1, e2, etc... }; } ...

Getting Started in Firmware devlopment

Hi, I am a software development guy. Oflate I was thinking of trying out some firmware development, as the company I work for is trying to enter that domain. I have many questions regarding firmware devlopment - like 1. What are the tools used - like IDE? 2. In which language is most of the code written in? 3. How to port the code int...

SOAP Message parameters - how to send strings and schemas

Hi I'm quite new to SOAP. I need to understand something failry basic I'm sure. First, the info: This method returns a list of all items in a database where a field matches a value. For example: WhereClause = "TypeCode = 'M'" Code //[some code] bool morePages; //[some other code] PartListDataSetType plType = proxy.GetList(CompanyNa...