-2
votes
2answers
33 views

Converting string array into json

My String array has the following output each time it iterates through the loop apple orange I want to convert my string array output to json format/jsonarray. I tried but it gives output as ...
-1
votes
1answer
48 views

String Array with enhanced for loop [duplicate]

A bit of advice needed here, I am trying to code Create a String Array containing any six first names. Use an enhanced for loop to print each name in the array Here is what I have: public class ...
24
votes
6answers
40k views

How to split a String by space

I need to split my String by spaces. For this I tried that: str = "Hello I'm your String"; String[] splited = str.split(" "); But it doesn't seems to work, what do I have to change?
4
votes
4answers
10k views

Check if String in String[] is in ArrayList<string>

What I've tried Hello Guys, I just builded a Broadcast Receiver with which I can get the incoming text messages, than I split the text message when there's a space and save it into a String[] Now ...
8
votes
6answers
230 views

Array syntax in Java: what is the significance of the [] location [duplicate]

String S[] = new String[3]; String[] S = new String[3]; Both ways are proper in Java. Does it mean that for every type Type[] x is the same as Type x[]?
0
votes
0answers
14 views

Change font in sans-serif-light from strings.xml

i've got an array string in my strings.xml <string-array name="categories"> <item>first</item> <item>second</item> <item>third</item> ...
0
votes
1answer
48 views

Android bold text in String-Array

I need to bold some text in a String Array, where each item is being used in a ViewPager. I am using getTextArray() to grab the formatted text from the xml file, and cannot cast that into a String to ...
0
votes
3answers
56 views

How to use String[] inputs in switch case in Android?

How to use the inputs of string array in switch case? String[] mon=new String[]{"January","February","March","April","May","June","July","August","September","October","November","December"}; switch ...
0
votes
2answers
147 views

How to convert or parse the response from the webservice to a String Array?

I return a String[] array from the webservice. And in my Android App I get the response like this: SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); SoapSerializationEnvelope envelope = ...
2
votes
7answers
81 views

End input of a string array

I am trying to take input of an array of strings (each string is a question) and my code is as follows: void read_quest()throws IOException { System.out.println("enter the questions(enter null to ...
0
votes
1answer
75 views

Searching String Array item in a nested HashMap

I have a nested HashMap (outer_map), which has another HashMap inside of it as a value (inner_map), such implemented as Map<String, HashMap<String, String>> outer_map = new ...
0
votes
0answers
32 views

Get the five closest addresses from String Array

I have a String array in Android (Java) with 175 elements which contains addresses. Now I need to sort the five closest addresses and make it to a list, I have got it to work with one element and a ...
-1
votes
3answers
60 views

How to change array list to string array for using Universal Image Loader?

I am a Novice of android. I just try to learn how to use Universal Image Loader. I find that the url of the images in Universal Image Loader are set statically or preset in String[] IMAGES. But I ...
0
votes
0answers
31 views

Set Color to String font in a JTable. (No cells, JLabel, JTextfield) Only String [][] and JTable [duplicate]

I have a JFrame, Panel, table all set. My table calls 2 different variables of string array to set the number of (x,y) for it. My arrays are: private String[] playerscore = ...
0
votes
0answers
17 views

Setting color to a specific string in JTable java [duplicate]

I have a JFrame, JPanel, and JTable. The table prints data from a string array. My table is 5x11 units. I need to set the text color of a specific unit. I set my string [] that my table. For example, ...
0
votes
0answers
36 views

Using String Arrays and ListView sticky headers

Im trying to use the StickyListHeaders library to create a listview with headers. Now my goal is to have groups of lists headed by their corresponding group name. Example. Manuals foo 1 bar 2 baz ...
0
votes
2answers
48 views

how to print on a JPanel / JLabel [duplicate]

So my code prints players names and scores all vertically on the JPanel, all the players first, then all their scores. I want to know how to print one after another alongside their scores. For ...
-4
votes
4answers
142 views

Null pointer exception in for loop [closed]

I try to get string that I don't want from string array by getting the array into for loop. I try the following code but I get java.lang.NullPointerException and I don't know why. Thank for helping. ...
0
votes
0answers
49 views

multiline string input for array

I am a java beginner trying to finish a school project and need help with syntax.... i am trying to write a question paper generator according to the icse pattern. I started with history/civics as the ...
2
votes
8answers
114 views

How to concat two string arrays in Java

I am using JDK 1.7 and Eclipse and trying to concat two string arrays: String [] a1 = { "a12", "b12" }; String [] a2 = { "c12", "d23", "ewe", "fdfsd" }; I have tried String[] both = ...
0
votes
4answers
42 views

Searching a String Array

For example if i have a string String [] grades = {"AAAB","ABAA","AABA"}; and i want to search the string array to see if any of the students achieved 3 or more A's. I know that you can search if ...
0
votes
1answer
67 views

get only the strings from a custom arraylist and make a string array using the strings

Objective: Create a new class (diaryLogs) with these fields to hold the values and a single constructor that takes an int (0 Mon, 1 Tue, 2 Wed etc) and two strings for the date time and diary entry ...
0
votes
0answers
52 views

reading files and store the method line in an string array

I have a java file 'Arithmetic.java', in which i have 2 overridden method. Now i wanted to read this file and i need to print all the method signature lines and have to put all the values in an ...
0
votes
3answers
94 views

Merging string-Array / arrayList without using loop

I was trying to do something like: ArrayList<String> getMerged ( String host, String port, String filesToCopy ){ ArrayList<String> merged = new ArrayList<String>(); ...
0
votes
0answers
15 views

Get Intent extras iteratively

In my android app I pass data from one activity to another via bundle string arrays. The data flows in the following fashion: MainActivity -> sends bundle string array in an Intent to Activity1. ...
-1
votes
7answers
81 views

how to convertfrom long to String [duplicate]

Hi i'm trying to convert long value into String but getting error Type mismatch: cannot convert from long to String This is the block of code please have a look URLConnection localURLConnection ...
0
votes
2answers
80 views

Java - Printing several different parts of a split string

I am having an error when I am trying to print out an Array. Though I am getting an: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at ...
0
votes
3answers
109 views

Java: Creating an array of random string numbers

I have a set of code that, currently, uses a pre-set list of 30 manually inputed strings made up of numbers, which can be seen below: String[] elementsToAdd2 = { "100", "510", "170", "214", ...
0
votes
0answers
123 views

Reading txt file, parsing into string array

I am reading in a text file and parsing it by creating a string array. What I am trying to do right now is read in only the first array object of each line, compare to a list of already defined ...
0
votes
2answers
36 views

why String Array did't tak a string as first Index

I have the following code. There is problem in String[] sep2=strAdder; compiler suggests that change the sep2 to String or change the type of strAdder to String[]. I am confused about that. I think it ...
0
votes
1answer
56 views

How to set values to a Combo Box using ssjs array variable?

I get values from Db using jdbc and store them in a String Array object. I have a combobox in an xpage and computed its values using ssjs. The java class has a function, String[] array = new ...
0
votes
1answer
63 views

Place String into 2 dimensional array

To put a String into a single array is easy but I want to put a string into a 2d char[][]; I'm stuck here, can some one help me please ... Thank u, ans sorry for my bad English! String woord = ...
0
votes
2answers
240 views

Cast error passing request.getParameterMap() to a method expecting Map<String,Object>

I started testing Tomcat 7 and found a cast error I hadn't experienced in Tomcat 5. Both versions of Tomcat are using the same path to Java 6. Here is the call from a JSP: ImcKaView ...
2
votes
4answers
4k views

How to convert string array to enum array in java

I have a string array that contains the enum values taken from the user. How do I now convert this string array to enum array so that the elements can then be iterated and used further in other ...
-4
votes
1answer
64 views

how to create array from string in java with respective data items [closed]

How to create an array from a string with two respective data items. String str="USA*2*Japan*8^2*India*5^4^2*Germany*5*"; Here, I want to create an array of two items in . Like this: ...
0
votes
2answers
55 views

Get strings between “ -— ” from the array

If I have a string array as follows: String[] name = {"aval", "H ---- ", "Singh", "Sawh", "Gopi", "G ---- ", "parminder", "kaur", "jaspreet", "asneet", " ---- "}; And if the user searches for the ...
0
votes
4answers
72 views

Splitting a string in substrings and putting those in a String []

So I have a string which i'm splitting up in substrings. Everyone of those substrings should become an element of a new String array. so far I have this: public static void main(String[] args) ...
0
votes
3answers
100 views

String array : Adding elements in Loop

Here is my code LDAPAttributeSet attributeSet = new LDAPAttributeSet(); String rolesName; String uniquemem[] = rolesName.split(","); if (uniquemem.length == 1) attributeSet.add(new ...
0
votes
7answers
150 views

Java string comparsion [duplicate]

I'm trying to implement a simple cesar cipher. I'm having trouble with the function that codes a string based on a new key[]. Here I shown, how I setup my key. private String[] alphabet = {"a", ...
0
votes
2answers
94 views

How to set 2 integer values to be the same

I am using a random variable, 2 string arrays and I am trying to set the 2 string arrays to have the same position value, I have tried all possible means, but none of them works. I am new to ...
1
vote
3answers
549 views

What is the difference between String[] and String… in Java?

How should I declare main() method in Java? Like this: public static void main(String[] args) { System.out.println("foo"); } Or like this: public static void main(String... args) { ...
2
votes
2answers
92 views

String array and string

i'm working on a program for my class but now i have a problem with spliting string and substrings. I have saved data from different classes in a string with a delimiter for later a later split(/). ...
1
vote
2answers
73 views

How do you check to compare a string value to each element in an array?

So I have a String Array (sConsonantArray) and have all of the consonants stored in it. String[] sConsonantArray = new String[] ...
1
vote
1answer
660 views

onClick Listener on DrawerLayout Does Not Launch Toast

I'm attempting to implement a toast depending on the item clicked in a DrawerLayout - however I cannot seem to get the toasts to appear no matter what I do. I'm not sure exactly what I did wrong: any ...
0
votes
3answers
2k views

How to convert String to byteArray and byteArray to String Array in java?

I want to convert String to bytearray in java.. For Example i want output like the following : String s = "82,73,70,70,90,95,3,0,87,65,86"; Now the logic is , i want same String value in bytearray ...
0
votes
0answers
42 views

g.drawstring string from String[]

I try to draw strings from String[]. This code doesen't seem to work. It's supposed to be somekind of chatsystem.. I'm also wondering if this is good or bad way to make chat system? For example is ...
1
vote
3answers
42 views

How can I return an error message if the type of args[i] is not of the expected type in Java? Is there a 'type test' function?

So this is a class that is meant to take in as input in the CMD prompt a string and integer, i.e. "Hello" 4, and then repeat the string 4 times. Thats not a problem, and works, however I want to ...
1
vote
1answer
58 views

Need help to convert Array into another array in Java

I need to organize this array. String [] students={"Paul", "A", "Paul", "B", "Mike", "B", "Cindy", "A", "Cindy", "B", "Cindy", "C"} The target is String [][] grades={{"Paul", "A", "B"} , {"Mike", ...
1
vote
3answers
57 views

java string split is not giving expected result

I'm trying to split a string into a string [] but im not getting the expected result. What is wrong here? String animals = "dog|cat|bear|elephant|giraffe"; String[] animalsArray = ...
0
votes
3answers
301 views

Sort String Array by alphabet and then by number

I have an String Array i have fileterd from a database with output like this in Java [ABCD XYZ M1210, ABCD XYZ M149, ABCD XYZ M5130, ABCD XYZ N1420, ABCD XYZ T11299, ABCD XYZ S11044] Im ...