---
title: "How to convert string to char array using java"  
description: "How to convert string to char array using java"  
author: "Anonymous User"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1658/how-to-convert-string-to-char-array-using-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How to convert string to char array using java

Is there a way in which a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) "hello" can be changed into a 'hello' in [java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming) ([android](https://www.mindstick.com/articles/13046/10-reasons-why-i-prefer-android-vs-iphone-ios))?? This is to make my [SQL query](https://www.mindstick.com/forum/529/rename-table-name-and-column-name-using-sql-query) work. For example

```
public Cursor GetLecture(String course_code)
{
    SQLiteDatabase sqldb = this.getReadableDatabase();
    String query = "SELECT * FROM Lecture WHERE course_code =" + course_code;
    Cursor C = sqldb.rawQuery(query, null);
    return C;
}
```

\

\

## Replies

### Reply by Hank Greenberg

Strings are sequence of characters delimited by double quotes. You can't delimit them by single quotes. Those are for characters. This one is in Java.

In case of [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver), to enclose your string in single quotes, you can do it like this:

```
String query = "SELECT * FROM Lecture WHERE course_code = '" + course_code + "'";
```


---

Original Source: https://www.mindstick.com/forum/1658/how-to-convert-string-to-char-array-using-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
