-
-
Save udacityandroid/aebbe8df6932e9c1c9bf to your computer and use it in GitHub Desktop.
String firstName = "Lyla"; | |
String lastName = "Fujiwara"; | |
String contactInfo = firstName + " " + lastName; | |
contactInfo = "<" + lastName + "." + firstName + "@justjava.com>"; | |
display(contactInfo); |
The Result of code
So This Not Correct
The Correct Code To Achieve The Goal Is
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = firstName + " " + lastName + "<" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
the code should be:
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = contactInfo + ”<“ + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
What is displayed would be:
Lyla FujiwaraFujiwara.Lyla@justjava.com
@Manoj0718 could you screen the code
not correct
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = "<" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);............................................<Fujiwara.Lyla@justjava.com>
to display the correct message the code will be
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = contactInfo + "<" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo= firstName+" "+lastName;
contactInfo+="<" + lastName+"."+firstName+"@justjava.com>";
display(contactInfo);
String firstName ="Lyla";
String lastName ="Fujiwara";
String contactInfo=firstName+" "+lastName;
contactInfo= contactInfo+"<"+lastName+"."+firstName+"@justjava.com>";
display(contactInfo);
hey everyone, I am getting the same errors as @R964 and @JobVilligran please help @udacityandroid
Given
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = "<" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
Corrected Code
String firstName = "Lyla ";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = " <" + lastName + "." + firstName + "@justjava.com>";
display(firstName + lastName + contactInfo);
Another option to correct program...
String firstName = "Lyla ";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = firstName + lastName + " <" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
Hey i got the
Error :- Stirng cannot be converted to int and i solved this issue so what we have to do is change the value of public void to string value
String firstName = "Lyla"; String lastName = "Fujiwara"; String contactInfo = firstName + " " + lastName; contactInfo = contactInfo + "<" + lastName + "." + firstName + "@justjava.com>"; display1(contactInfo);
// This is the right java code and the programme will run fine .
public void display1(String text) { TextView t = (TextView) findViewById(R.id.display_text_view); t.setText(text); }
Happy to Help
`package com.example.android.practiceset2;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo = contactInfo + " <" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
}
/**
* Display methods that allow the text to appear on the screen. Don't worry if you don't know
* how these work yet. We'll be covering them in lesson 3.
*/
public void display(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText(text);
}
public void display(int text) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText(text + "");
}
public void display1(String text) {
display(text);
}
public void display2(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view_2);
t.setText(text);
}
public void display3(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view_3);
t.setText(text);
}
}`
The fix is
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
contactInfo +="<" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
package com.example.android.practiceset2;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String firstName = "Lyla";
String lastName = "Fujiwara";
String conttactInfo = firstName + " " + lastName;
conttactInfo = "<" + lastName + "." + firstName + "@justjava.com>";
display(conttactInfo);
}
/**
* Display methods that allow the text to appear on the screen. Don't worry if you don't know
* how these work yet. We'll be covering them in lesson 3.
*/
public void display(String i) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText(""+ i);
}
}
<TextView
android:id="@+id/display_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="45sp" />
it's displaying:
Fujiwara.Lyla@justjava.com
package com.example.android.practiceset2;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// PASTE CODE YOU WANT TO TEST HERE
String firstName = "Lyla";
String lastName = "Fujiwara";
String contactInfo = firstName + " " + lastName;
String contactName = firstName + " " + lastName;
contactName = (firstName + " " lastName);
contactInfo = "<" + firstName + "." + lastName + "@justjava.com>";
display(contactName);
display2(contactInfo);
}
/**
* Display methods that allow the text to appear on the screen. Don't worry if you don't know
* how these work yet. We'll be covering them in lesson 3.
*/
public void display(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText(text);
}
// public void display(int text) {
// TextView t = (TextView) findViewById(R.id.display_text_view);
// t.setText(text + "");
// }
public void display1(String text) {
display(text);
}
public void display2(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view_2);
t.setText(text);
}
public void display3(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view_3);
t.setText(text);
}
}
This worked for me...
Done!
package com.example.android.practiceset2;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// PASTE CODE YOU WANT TO TEST HERE
// int weekday = 5;
// int weekend = 9;
// int optimalHours = 7 * 8;
// int actualHours = weekday;
// actualHours = actualHours + weekend * 2;
// int solution = optimalHours - actualHours;
// display(solution);
// int dollars = 40;
// int dollarsToYen = 119;
// int yen = dollarsToYen * dollars;
// display(yen);
String firstName = "Shiva";
String lastName = "Shankar";
String contactInfo = firstName + " " + lastName;
contactInfo = "<" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
}
/**
* Display methods that allow the text to appear on the screen. Don't worry if you don't know
* how these work yet. We'll be covering them in lesson 3.
*/
public void display(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText(text);
}
public void display(int text) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText(text + "");
}
public void display1(String text) {
display(text);
}
public void display2(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view_2);
t.setText(text);
}
public void display3(String text) {
TextView t = (TextView) findViewById(R.id.display_text_view_3);
t.setText(text);
}
}
Maybe
String firstName = "Lyla";
String lastName = "Fujiwara";
String fullName = firstName + " " + lastName;
String contactInfo = "<" + lastName + "." + firstName + "@justjava.com>";
display(fullName + contactInfo);
This worked for me :
String firstName = "Lyla ";
String lastName = "Fujiwara";
String contactInfo = firstName + lastName + " <" + lastName + "." + firstName + "@justjava.com>";
display(contactInfo);
- I merged the 3rd line with the 4th line and removed the double quotes in the third line
- I also added a space to the string of the first name, to create a space between the first and last name
Not correct.
it's displaying:
Fujiwara.Lyla@justjava.com