| | |
setting a string to a char
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 18
Reputation:
Solved Threads: 0
for this code I need to set string d to char c, can anyone tell me how to do it?
public static void main(String[] args)
{
int n;
int m;
String d;
char c;
Scanner sc = new Scanner(System.in);
System.out.println("Input Integer: ");
//get the value
n=sc.nextInt();
int answer = sum_upto(n);
System.out.println("sum of numbers from 1 to n: " + answer);
System.out.println("input a character and two integers: ");
//get the values
d=sc.next();
n=sc.nextInt();
m=sc.nextInt();
d.charAt(0);
System.out.println(writeBlock(c, m, n));
}•
•
Join Date: May 2008
Posts: 38
Reputation:
Solved Threads: 2
hi,
i think you are already getting the String in to the Character, but you should replace
with
Thats it really , as we already know that String is like an array of characters. So according to my understanding you are right.
i think you are already getting the String in to the Character, but you should replace
Java Syntax (Toggle Plain Text)
d.charAt(0);
Java Syntax (Toggle Plain Text)
c = d.charAt(0);
![]() |
Similar Threads
- very strange string behaviur.. (C)
- Array data not setting (C++)
- Search Method help needed!!! (Java)
- string input not working as expected (C++)
- problem with fstream (C++)
- Structure char field to a disk file (C)
- Geting elements from a String Array (C++)
- need help in creating class string (C++)
- Arrays (C++)
Other Threads in the Java Forum
- Previous Thread: button listener question
- Next Thread: Problem: Instant Messenger
| Thread Tools | Search this Thread |
6 actuate android api applet application array arrays automation balls binary bluetooth bold business c++ chat class classes client code codesnippet collections component coordinates database defaultmethod doctype dragging ebook eclipse educational error event exception file fractal froglogic game givemetehcodez graphics gui helpwithhomework hql html ide ideas image ingres input integer internet intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list loop looping map method methods mobile mysql netbeans newbie nextline parameter php print problem program programming project recursion recursive scanner screen sell server set size sms sort sql string sun swing swt threads tree user websites windows





