JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Servlet/JSP 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 關於字串問題?
esther75952

↖ 月 晦 ↘



發文: 44
積分: 0
於 2006-12-04 14:03 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@ page contentType="text/html;charset=big5" language="java" %>
<html>
<body>
<%
String _a = "1*2*3";
String m1=_a.substring(0,1);
String m2=_a.substring(2,3);
String m3=_a.substring(4,5);
String m4=_a.substring(1,2);

out.println(m1 * m2 * m3);
%>
</body>
</html>
各位大大~我想寫出1*2*3的值~~6
可是會出現錯誤,麻煩各位大大幫我看一下,哪裡錯誤了, ~謝謝


esther75952 edited on 2006-12-04 14:15
reply to postreply to post
skip beat 爆愛看^ ^
作者 Re:關於字串問題? [Re:esther75952]
yupin





發文: 343
積分: 1
於 2006-12-04 15:57 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
out.println(m1 * m2 * m3);

m1,m2,m3 都是 String,不能拿來做運算!


reply to postreply to post
養了一隻獵犬,結果......現在變成神豬了!
作者 Re:關於字串問題? [Re:esther75952]
esther75952

↖ 月 晦 ↘



發文: 44
積分: 0
於 2006-12-04 16:11 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝yupin大大,我後來有想到了,
字串不能做運算,
可是我不會把字串轉換成字元耶,
煩請大大教我一下
謝謝


reply to postreply to post
skip beat 爆愛看^ ^
作者 Re:關於字串問題? [Re:esther75952]
bernardvai





發文: 491
積分: 0
於 2006-12-04 18:08 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
esther75952 wrote:
謝謝yupin大大,我後來有想到了,
字串不能做運算,
可是我不會把字串轉換成字元耶,
煩請大大教我一下
謝謝


從 Java 基礎學起吧 !!


reply to postreply to post
作者 Re:關於字串問題? [Re:esther75952]
shasun





發文: 118
積分: 0
於 2006-12-04 18:09 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
esther75952 wrote:
謝謝yupin大大,我後來有想到了,
字串不能做運算,
可是我不會把字串轉換成字元耶,
煩請大大教我一下
謝謝


有空多看javadoc囉!
http://java.sun.com/j2se/1.3/docs/api/java/lang/Integer.html


reply to postreply to post
作者 Re:關於字串問題? [Re:esther75952]
esther75952

↖ 月 晦 ↘



發文: 44
積分: 0
於 2006-12-05 11:34 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝大大~~我的問題解決了~~謝謝你們囉

reply to postreply to post
skip beat 爆愛看^ ^
作者 Re:關於字串問題? [Re:esther75952]
welcomeyouat





發文: 8
積分: 0
於 2007-01-08 15:05 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
int a=Integer.parseInt(m1);

reply to postreply to post
» JWorld@TW »  Servlet/JSP 討論區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8