• Register
Welcome to Kodlogs Q&A, where you can ask programming questions and receive answers from other members of the community. For programmers, by programmers Kodlogs is an open community for anyone that does coding. We help you get answers to your toughest coding questions, share knowledge with your coworkers in private, and find your next IT dream job.

Most popular tags

java program php python javascript c# android r c spring-boot arrays html mysql entity-framework sql-server matlab redirect code program numpy spring asp loop net class quirks-mode internet-explorer-9 internet-explorer machine-learning winforms visual-studio-2010 webpack python-3 python-2 aspnet dataframe pandas jdbc ios eclipse sum loops css cmd tcp math security jquery sockets sql 7 number firebase-authentication aws-organizations amazon-web-services php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys sql-server-2005 windows-services react-redux reactjs inputstream facebook-graph-api for-loop entity-framework-4 reportingservices-2005 reporting-services mips linear-regression scikit-learn anova deep-learning keras block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx indentation-error eclipseide javafx-2 php-not-recognized laravel command-line unit-testing tinyurl atom-editor android-emulator android-studio android-sdk-tools ionic2 cordova jupyter-notebook foobar2k tcplistener net-2 net-4 ole-db-provider windows-10 vagrantfile ggplot2 glmnet jvm-arguments global-variables orm virtualenv atom xls oledb redux webclient prediction headless hyperlink outlook pipeline iis perfect-square objective-c carthage xcode8 compiler-errors numpy-ndarray standard-deviation xampp apple mdf destructor vagrant gettime gmail ioexception heuristics milliseconds reporting cpu npm modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jtextfield jpanel inputmismatchexception deque jupyter javafx lvalue junit tensorflow ibm factorial servlet apache boot virtualbox indentation jvm margins 2147483647 xcode firebase plot deployment processor automation socketexception pointers concatenation oracle devices color recursion sequence search date caching expected response directory csv algorithms release collections facebook float figure url expression microsoft sorting sort datetime httpwebrequest cryptography json ajax exe dictionary required windows string variable size dll system exception files x int function random import code 2
0 votes
5 views
illegal start of expression java
by (1.5k points)  
reshown by

1 Answer

0 votes

Fix  for "illegal start of expression" error in Java:

In error called illegal start of expression there's two types of
errors :
1)syntax errors things that are not correct and then we
have a lot of exceptions which gets
thrown at at runtime this one happens to
be a syntax type error and it's very
common especially when you're starting
out in programming so in this example I
have my main method and I thought well
you know the first thing I want to do is
I'll create a method to get my user data
or return some kind of string like maybe
their name or something and I typed it
and I'm looking at it going wow that's
that's the exact pattern I'm supposed to
make for a method right it's got an
access identifier public private or
protected you know this case it's static
it returns a string I I've got a name I
got brackets it should be getting but I
get this error even legal start of
expression and what that's telling us is
actually here we have the main method
and you can see highlighted in yellow
you can see the start of the main method
and then the end of the main method then
inside of it I have my new method this
get user data method and you can't have
it that way
methods have to exist unto themselves
well thanks for here so this method
starts and stops and then a new method
starts and stops and then the other area
that we're seeing here is has missing
return statement now what that means is
here when I declared the method header
it has a return type in this case string
to be int or double or student or any
type of object but it's telling the
system that I'm going to return
something to whatever method calls it
because there's nothing here it's as I'm
missing a return statement so I'll have
to do is return something it's been a
piece and say return yeah and then my
air is going to go away so the two
items here illegal started expression is
usually a bracketing issues to just make
sure you look at the start and finish of
each method and then the other one we
looked at is missing return statement
which means if you say you're going to
return something in your code you have
to get to a point where you can return
things another scenario that people get
confused at is it says like if you know
five is less than four from yeah in this
case it may look like we've got a return
statement but we still get this error
and the reason is this condition in the
if statement we're going to have some
kind of conditional statement here so
it's quite possible that we never get to
this line of code so it is in this
scenario you'd have to rate in else and
then return I hate to whenever you say
you return something your code at some
point has to get to a line of code that
says return and otherwise you will see
that a missing return statement error
.
by (8.9k points)  
...