Click here to Skip to main content
15,435,438 members
Home / Discussions / Java
   

Java

 
GeneralRe: java program Pin
Richard MacCutchan17-Jan-22 0:39
mveRichard MacCutchan17-Jan-22 0:39 
AnswerRe: java program Pin
Prashanth Rao 202118-Jan-22 23:18
MemberPrashanth Rao 202118-Jan-22 23:18 
Questionhow do i properly connect my external style sheet link to my jsp page. Pin
jonathanIckovich25-Dec-21 19:42
MemberjonathanIckovich25-Dec-21 19:42 
QuestionWhat is causing error in my merge sort java code? Pin
Vivek Halakatti3-Dec-21 5:20
MemberVivek Halakatti3-Dec-21 5:20 
AnswerRe: What is causing error in my merge sort java code? Pin
Richard MacCutchan3-Dec-21 6:09
mveRichard MacCutchan3-Dec-21 6:09 
QuestionWhat may be the error in this java ->merge sort code? Pin
Vivek Halakatti2-Dec-21 7:15
MemberVivek Halakatti2-Dec-21 7:15 
AnswerRe: What may be the error in this java ->merge sort code? Pin
Richard Deeming2-Dec-21 21:29
mveRichard Deeming2-Dec-21 21:29 
QuestionWhy am I getting an error concatenating a String in java 16? Pin
Toml61828-Nov-21 6:13
MemberToml61828-Nov-21 6:13 
I am trying to extract date from a String (Line), to do a Date conversion, but my String concatenation (#1) gives incorrect result.
Adding a blank ("") at the start (#2) gives the correct result.
Why is this? Where does the "105" come from?


Java
//=========================================================
System.out.println("Line= " + Line);

char ch1 = Line.charAt(0), ch2 = Line.charAt(1);
char ch4 = Line.charAt(3), ch5 = Line.charAt(4);
char ch7 = Line.charAt(6), ch8 = Line.charAt(7),
     ch9 = Line.charAt(8), ch10 = Line.charAt(9) ;
System.out.println("Text date= " + ch1 + ch2 + '/' + ch4 + ch5 + '/' +
     ch7+ ch8+ch9+ch10);

//#1 concatenate is wrong
String sDate1= ch1 + ch2 + "/" + ch4 + ch5 + '/' +
         ch7+ ch8+ch9+ch10;
System.out.println("Not correct: sDate1= " + sDate1);

//#2: For some reason, adding a blank at the start gives correct result
String sDate2= "" + ch1 + ch2 + "/" + ch4 + ch5 + '/' +
     ch7+ ch8+ch9+ch10;
System.out.println("Correct:     sDate2= " + sDate2);
//=============================================================


Output:
Line= 09/12/2021
Text date= 09/12/2021
Not correct: sDate1= 105/12/2021
Correct: sDate2= 09/12/2021
AnswerRe: Why am I getting an error concatenating a String in java 16? Pin
Gerry Schmitz28-Nov-21 7:58
mveGerry Schmitz28-Nov-21 7:58 
QuestionRe: Why am I getting an error concatenating a String in java 16? Pin
Richard MacCutchan28-Nov-21 8:13
mveRichard MacCutchan28-Nov-21 8:13 
AnswerRe: Why am I getting an error concatenating a String in java 16? Pin
Toml61828-Nov-21 9:55
MemberToml61828-Nov-21 9:55 
Questionhelp with 2d cellular automata in JavaSwing Pin
Suave6519-Nov-21 9:10
MemberSuave6519-Nov-21 9:10 
QuestionRe: help with 2d cellular automata in JavaSwing Pin
Richard MacCutchan19-Nov-21 21:55
mveRichard MacCutchan19-Nov-21 21:55 
QuestionSending BufferedImage thought a socket Pin
Valentinor8-Oct-21 2:10
MemberValentinor8-Oct-21 2:10 
AnswerRe: Sending BufferedImage thought a socket Pin
jschell24-Oct-21 6:53
Memberjschell24-Oct-21 6:53 
GeneralRe: Sending BufferedImage thought a socket Pin
Valentinor24-Oct-21 21:40
MemberValentinor24-Oct-21 21:40 
GeneralRe: Sending BufferedImage thought a socket Pin
jschell23-Dec-21 5:29
Memberjschell23-Dec-21 5:29 
AnswerRe: Sending BufferedImage thought a socket Pin
Gerry Schmitz25-Oct-21 8:35
mveGerry Schmitz25-Oct-21 8:35 
AnswerRe: Sending BufferedImage thought a socket Pin
Joop Eggen 202125-Nov-21 6:15
MemberJoop Eggen 202125-Nov-21 6:15 
QuestionJava Programming Challenge Pin
Purvesh Ptdr24-Sep-21 18:22
MemberPurvesh Ptdr24-Sep-21 18:22 
QuestionRe: Java Programming Challenge Pin
Richard MacCutchan24-Sep-21 21:19
mveRichard MacCutchan24-Sep-21 21:19 
Questionjava jshell beanshell eval string Pin
Majid Karimi27-Aug-21 23:45
MemberMajid Karimi27-Aug-21 23:45 
AnswerRe: java jshell beanshell eval string Pin
jschell5-Sep-21 8:55
Memberjschell5-Sep-21 8:55 
QuestionDefault Casting a column to type using Hibernate Pin
ficevivu3-Aug-21 19:50
Memberficevivu3-Aug-21 19:50 
QuestionHow to make a scrolling background for a JPanel in java? Pin
Mr.Corona13-Jul-21 1:51
MemberMr.Corona13-Jul-21 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.