Java: String concatenation

This entry is part 6 of 54 in the series Learn Java

In Java, a string can be concatenated together using the + operator.

The following example will join 2 strings and a blank space.  The blank space is also a string.

package javaapplication5;

public class JavaApplication5 {

    public static void main(String[] args) {
        
        String a = "Every Picture Tells A Story";
        String b = "by Rod Stewart";
        
        String title = a + " " +  b;
        
        System.out.println(title);      
    }   
}

string

MySQL: Handling empty string

This entry is part 12 of 26 in the series Learn MySQL

At times, we might come across a data that has an empty record or an empty string.

As in the screenshot below, this is inserted by:

insert into artist (artiste, album, price) values ('Bruce Springsteen','',9.60)

empty

 

If you are new to SQL, you could have wrongly interpreted this as a NULL string.

It is actually an empty string and it can be queried by =” as in:

select * from artist where album=''

Parse & JS: Queries on String

This entry is part 25 of 25 in the series Parse & Javascript

Use startsWith to restrict to string values that start with a particular string.

Similar to MySQL LIKE operator, this is indexed so it is efficient for large dataset.

<!doctype html>
<head>
    <title>My Parse App</title>
    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
    <script type='text/javascript' src='http://www.parsecdn.com/js/parse-1.2.17.min.js'></script>
</head>

<body>

<script>
    Parse.initialize('5d3sro43zBGj8AMYqWND5bFYMzAan7f5P5euZm7M', 'hlRZZqAylA7Fmah4Kk6ma8WK7QCT4cHrxjafnnkI');
    var MoviObject = Parse.Object.extend('MoviObject');
    var moviObject = new MoviObject();

    var query = new Parse.Query(MoviObject);

    query.startsWith('titleName', 'Scent');

    query.find(
            {
                success: function (moviObject) {
                    document.write('<h2>Movie Found:</h2>');
                    var title = moviObject[0].get('titleName');
                    document.write(title);
                }
            }
    );
</script>
</body>
</html>
Try The Code

startwith

PHP: String operators

This entry is part 17 of 54 in the series PHP Tutorial

Earlier, we have used .(dot) to join 2 strings together.

<?php

$text1 = 'Hello ';
$text2 = $text1 . 'World!'; 

echo "$text2";
echo "\n";

$text3 = 'Upwhere We ';
$text3 .= 'Belong!';  

echo "$text3";
echo "\n";

$num = 3;

echo "Result: " . ($num + 3); 

?>

In the statement $text3 .= ‘Belong!’, the .(dot) here is a unary string operator.

The statement here will add ‘Belong!’ to variable $text3 itself.