|
I have a variable that can either contain a list of strings or a just a string. Is there a good way to tell what kind I'm dealing with?
"192.168.1.18" vs. ["192.168.1.18", "192.168.1.19"]
In either case I want to use the bits involved.
Started by Fylke on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
An alternative would be when generating this string/list of strings to always put.
Or if you are not interested in actually pulling apart the string/list of strings you could do:
if is_list earlier.
|
|
Question I would like to be able to use a single regex (if possible) to require that a string fits [A-Za-z0-9_] but doesn't allow:
Strings containing just numbers or/and symbols. Strings starting or ending with symbols Multiple symbols next to eachother...
Started by epochwolf on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
Look ahead to make sure there's at least one letter in the string, then start consuming input.
|
|
What is the most suitable container just for strings holding in some array with non-predetermined upper boundary, which length is unknown on it's creation.
For simple code like:
Foo list = new Foo(); // size in unknown for()/foreach()/do()/while() // ...
Started by abatishchev on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The Collection<T> class is just.
A StringCollection is just a type safe ( Find , Sort , etc)
A List<T> would be the most efficient.
Have to cast the items to String when reading from it.
|
Ask your Facebook Friends
|
Which is more efficient for the compiler and the best practice for checking whether a string is blank?
Checking whether the length of the string == 0 Checking whether the string is empty (strVar == "") Also, does the answer depend on language?
Started by Haydar on
, 13 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
Pascal-type strings the best way to determine....
You basically just pay for an extra functionYes, it depends on language, since string storage differs between languages.
Checking the first character in the string are both O(1).
|
|
I'm a C++ guy learning Java. I'm reading Effective Java and something confused me. It says never to write code like this:
String s = new String("silly");
Because it creates unnecessary String objects. But instead it should be written like this:
String...
Started by JavaNewbie on
, 15 posts
by 15 people.
Answer Snippets (Read the full thread at stackoverflow):
Nor can you extend ....
There's no way for your SomeStringClass cis = "value" example to apply to any other class .
String s are special in Java - they're immutable, and string constants are automatically turned into String objects.
|
|
Can someone explain to me why ServletRequest.getParameterMap() returns type
Map<String, String[]>
ServletRequest.getParameter() just returns type String
I'm don't understand why the map would ever map to more then one value. TIA.
Started by BillMan on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Opel</option> </select>
Any checked/selected values will come in as:
String[] cars parameter values is
request.getParameterValues();
getParameter() is just a shortcut to get first one..
|
|
Ended up with this awful data structure:
List<KeyValuePair<string, KeyValuePair<string, string>>>
It's not likely to get huge (<1K I estimate) and I am gonna iterate this list over and over.
Anyone can think of some better alternative...
Started by JohnIdol on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Tuple<string,string,string>>
This is easy enough to write in .NET 2.0 - it's basically juststruct MrStruct { public string Key1, public string Key2, public string Value1 } List< dramatically speed up any ....
|
|
Really on the fence about getting a 7 string. For recording purposes, it would be nice to leave the 6 string for everything BUT the super heavy stuff (as opposed to having to use a single guitar for multiple tunings).
So do I just make the leap to a 7...
Started by Gainzilla on
, 39 posts
by 21 people.
Answer Snippets (Read the full thread at rig-talk):
But....
I was just thinking about.
So do I just make the leap to a 7 String or just get another 6 string the feel of a 6 string over all the 7 strings I've had.
Guitar for multiple tunings).
|
|
Possible Duplicates:
In C# what is the difference between String and string
String vs string in C#
what is difference between String and string(data type) in c# asp.net?
Started by Domnic on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The first is just.
There's no difference.
string is an alias.
System.String is the datatype.
|
|
I work with different servers and configurations. What is the best java code approach for getting the scheme://host:[port if it is not port 80].
Here is some code I have used, but don't know if this is the best approach. (this is pseudo code)
HttpServletRequest...
Started by Berlin Brown on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
(That's the one you want.) Group 2 contains....
URI u=new URI("http://www.google.com/"); String s(), request.getServerName(), port, "");
public String getServer(HttpServletRequest request) { int port.
I think java.net.URI does what you want.
|